Exam Questions and CORRECT Answers
primitive data types - CORRECT ANSWER - byte, short, int, long, float, double, char,
boolean
non primitive data types - CORRECT ANSWER - Array
String
Which would correctly declare and instantiate an array of 5 ints? - CORRECT ANSWER -
int[] values = new in[5];
2D arrays the first term goes __ and the second is __ - CORRECT ANSWER - down,
across
every java program consists of at least one - CORRECT ANSWER - class definition
Method overloading distinguishes between methods based on __ - CORRECT ANSWER -
signature/paramater
What structure is commonly used to iterate over all the elements of a two dimensional array? -
CORRECT ANSWER - nested loop
Foo x = new Foo(51), y = new Foo(73);
y.i = x.i;
y.i = 12;
System.out.println(x.i); - CORRECT ANSWER - 73
, immediately after the objects variables are initialized - CORRECT ANSWER - a
constructor is called
a value type variable stores a - CORRECT ANSWER - value
t or f
a name defined in an outer scope is not available in all blocks nested inside that scope -
CORRECT ANSWER - false
the purpose of a constructor is to - CORRECT ANSWER - initialize an object to a valid
state
Foo x = new Foo(86), y = new Foo(69);
y = x;
y.i = 7;
System.out.println(x.i); - CORRECT ANSWER - 7
Foo x = new Foo(18), y = new Foo(75);
x = y;
y.i = 23;
System.out.println(x.i); - CORRECT ANSWER - 23
an object and the variable that refers to it are two different things - CORRECT ANSWER -
true
a default constructor takes __ arguments - CORRECT ANSWER - 0
an object is an instance of a class - CORRECT ANSWER - true