Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Question 1 (5 points) How many parameters does a default constructor have?

Question 1 (5 points)

How many parameters does a default constructor have?

Question 1 options:

It depends on the constructor
It can have 0 or 1
Always has 1
It never has any

Save

Question 2 (5 points)

Which of the following statements is true about the class shown below?

class Quiz1A
{
private int[] array = new int[10];
public int[] getArray()
{
return array;
}
}

Question 2 options:

It is mutable because it has an accessor method that returns a reference to a mutable instance variable
It is immutable
It is mutable because it contains a public method
It is mutable because it contains a mutator method

Save

Question 3 (5 points)

A method that is associated with an individual object is called __________.

Question 3 options:

a class method
an instance method
a static method
an object method

Save

Question 4 (5 points)

Given the declaration Circle[] x = new Circle[10], which of the following statement is most accurate?

Question 4 options:

x contains an array of ten int values.
x contains a reference to an array and each element in the array can hold a reference to a Circle object.
x contains an array of ten objects of the Circle type.
x contains a reference to an array and each element in the array can hold a Circle object.

Save

Question 5 (5 points)

What is the output of the program shown below?

public class Quiz1B
{
public static void main(String[] args)
{
Count count = new Count();
int times = 0;

for (int i = 0; i < 100; i++)
increment(count, times);
System.out.println(“times = ” + times + ” count = ” + count.times);
}

public static void increment(Count count, int times)
{
count.times++;
times++;
}
}

class Count
{
int times;

public Count()
{
times = 1;
}

Question 5 options:

times = 0 count = 101
times = 100 count = 1
times = 0 count = 1
times = 100 count = 101

Question 6 (5 points)

When calling a method with an object argument, ___________ is passed.

Question 6 options:

the object is copied, then the reference of the copied object
the contents of the object
a copy of the object
the reference of the object

Save

Question 7 (5 points)

Which of the following is not a property of a constructor?

Question 7 options:

The name of a constructor can be chosen by the programmer
A constructor must have the same name as the class
Constructors may be overloaded
A constructor is called using the new operator

Save

Question 8 (5 points)

What is the output of the program shown below?

public class Quiz1C
{
public static void main(String[] args)
{
int i = 1;
StringBuilder s = new StringBuilder(“s”);
String t = “t”;

someMethod(i, s, t);
System.out.print(“i = ” + i + “, “);
System.out.print(“s = ” + s + “, “);
System.out.println(“t = ” + t);
}

private static void someMethod(int i, StringBuilder s, String t)
{
i++;
s.append(“s”);
t += “t”;
}
}

Question 8 options:

i = 1, s = s, t = t
i = 2, s = ss, t = tt
i = 1, s = ss, t = t
i = 2, s = ss, t = t

Save

Question 9 (5 points)

Which of the following statements is true about the order of methods in a class.

Question 9 options:

They must be in alphabetical order by name
The order depends upon which compiler is used
They can be listed in any order
Each method must be listed before any method it calls

Save

Question 10 (5 points)

Which of the following statements about constructors is true?

Question 10 options:

There must be at least one constructor with no parameters
At least one constructor must always be defined explicitly
A default constructor is provided automatically if no constructors are explicitly declared in the class
Every class has a default constructor

Save

Question 11 (5 points)

Which of the following is true about the program shown below?

class Quiz1D
{
private int x;

public Quiz1D(int x)
{
this.x = x;
}
}

Question 11 options:

If the this qualifier is removed, it will compile but won’t initialize the instance variable
If the this qualifier is removed, it will still compile and properly initialize the instance variable
It will not compile if the this qualifier is removed
It will not compile because there it contains a duplicate variable

Save

Question 12 (5 points)

Which of the following statements about local variables is true?

Question 12 options:

Every method must have at least one local variable
Java assigns a default value to a local variable in a method if the variable is not initialized
A compilation error results when a local variable is accessed before it is initialized
Local variables retain their values from one method to the next

Save

Question 13 (5 points)

Analyze the code shown below and indicate which of the following is true:

class Quiz1E
{
private double variable;

public Quiz1E(double variable)
{
variable = variable;
}
}

Question 13 options:

The program does not compile because Quiz1E does not have a default constructor
The program has a compilation error because it does not have a main method
The program has a compilation error because you cannot assign variable to variable
The program will compile, but you cannot create an object of Quiz1E with a specified value for variable

Save

Question 14 (5 points)

Which of the following is true of public methods?

Question 14 options:

They can only be accessed by methods in the same package
They can only be accessed by methods in the same class
They can only be accessed by methods in a different package
They can be accessed by any method in the same program

Save

Question 15 (5 points)

Which of the following statements is true about an immutable object?

Question 15 options:

An immutable object contains at least one mutator method
All instance variables of an immutable object must be public
The contents of an immutable object cannot be modified
All instance variables of an immutable object must be of primitive types.

Save

Question 16 (5 points)

What is the output of the program shown below?

public class Quiz1F
{
private static int i = 0;

public static void main(String[] args)
{
{
int i = 3;
}
System.out.println(“i is ” + i);
}
}

Question 16 options:

i is 0
i is 3
i is 2
i is 1

Save

Question 17 (5 points)

Which of the following statements is true of the reserved word this?

Question 17 options:

It can only be used in constructors
It can be only used in static methods
It can be only used in instance methods and constructors
It can be used in any method

Save

Question 18 (5 points)

Which of the following statements is true about the class shown below?

public class Quiz1G
{
private void method()
{
}

public static void main(String[] args)
{
method();
}
}

Question 18 options:

It won’t compile because method must be declared after main
It won’t compile because method must be public
It won’t compile because method needs to be static
It will compile without any problem

Save

Question 19 (5 points)

Which of the following statements is true of private instance variables?

Question 19 options:

They can accessed in any instance method in the same class
They can be accessed by any class in the same program
They can be accessed by any class in the same package
They can only be accessed by static methods in the same class

Save

Question 20 (5 points)

Which of the following statements about class (static) variables is correct?

Question 20 options:

The number of copies of each class variable depends upon the code provided in the constructor
There is no way to predict how mant copies of a class variable will exits in any given program
Each instance of the class has a separate copy of very class variable
There is only one copy of each class variable that is shared by all instances of the class

Bottom of Form

Question 1(5 points)How many parameters does a default constructor have?Question 1 options:It depends on the constructorIt can have 0 or 1Always has 1It never has anySaveQuestion 2(5 points)Which of the following statements is true about the class shown below?class Quiz1A{private int[] array = new int[10];public int[] getArray(){return array;}}Question 2 options:It is mutable because it has an accessor method that returns a reference to a mutable instancevariableIt is immutableIt is mutable because it contains a public method
Background image of page 01
It is mutable because it contains a mutator methodSaveQuestion 3(5 points)A method that is associated with an individual object is called __________.Question 3 options:a class methodan instance methoda static methodan object methodSaveQuestion 4(5 points)Given the declaration Circle[] x = new Circle[10], which of the following statement is most accurate?Question 4 options:x contains an array of ten int values.x contains a reference to an array and each element in the array can hold a reference to a Circleobject.x contains an array of ten objects of the Circle type.x contains a reference to an array and each element in the array can hold a Circle object.
Background image of page 02
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"