PRO192 Chapter 1-3 Practise Question Reviews
Chapter 1
Which of the following are valid declarations? Assume
java.util.*
is imported.
A.
Vector<Map> v;
B.
Set<String> s;
C.
Map<String> m;
D.
Map<String, String> m;
(3 answer) ** Answ** a,b,d
You can determine all the keys in a Map in which of the following ways?
A.
By getting a Set object from the Map and iterating through it.
B.
By iterating through the Iterator of the Map.
C.
By enumerating through the Enumeration of the Map.
D.
By getting a List from the Map and enumerating through the List.
E.
You cannot determine the keys in a Map. ** Answ** a
What keyword is used to prevent an object from being serialized?
A.
private
B.
volatile
C.
protected
D.
transient
E.
None of the above ** Answ** d
,An abstract class can contain methods with declared bodies.
A.
True
B.
False ** Answ** a
Select the order of access modifiers from least restrictive to most restrictive.
A.
public
,
private
,
protected
, default
B.
default,
protected
,
private
,
public
C.
public
, default,
protected
,
private
D.
default,
public
,
protected
,
private
E.
public
,
protected
, default,
private ** Answ** e
Which access modifier allows you to access method calls in libraries not created in
Java?
A.
public
B. static
, C. native
D. transient
E. volatile ** Answ** c
Which of the following statements are true? (Select all that apply.)
A. A final object's data cannot be changed.
B. A final class can be subclassed.
C. A final method cannot be overloaded.
D. A final object cannot be reassigned a new address in memory.
E. None of the above. ** Answ** d
The keyword extends refers to what type of relationship?
A. "is a"
B. "has a"
C. "was a"
D. "will be a"
E. None of the above ** Answ** a
Which of the following keywords is used to invoke a method in the parent class?
A. this
B. super
C. final
D. static ** Answ** b
Given the following code, what will be the outcome?
public class Funcs extends java.lang.Math {
public int add(int x, int y) {
return x + y;
}
public int sub(int x, int y) {
return x - y;
}
public static void main(String [] a) {
Funcs f = new Funcs();
System.out.println("" + f.add(1, 2));
}
}
A. The code compiles but does not output anything.
B. "3" is printed out to the console.
C. The code does not compile.
D. None of the above. ** Answ** c
Given the following code, what is the expected outcome?
public class Test {
public static void main(String [] a) {
int [] b = [1,2,3,4,5,6,7,8,9,0];
Chapter 1
Which of the following are valid declarations? Assume
java.util.*
is imported.
A.
Vector<Map> v;
B.
Set<String> s;
C.
Map<String> m;
D.
Map<String, String> m;
(3 answer) ** Answ** a,b,d
You can determine all the keys in a Map in which of the following ways?
A.
By getting a Set object from the Map and iterating through it.
B.
By iterating through the Iterator of the Map.
C.
By enumerating through the Enumeration of the Map.
D.
By getting a List from the Map and enumerating through the List.
E.
You cannot determine the keys in a Map. ** Answ** a
What keyword is used to prevent an object from being serialized?
A.
private
B.
volatile
C.
protected
D.
transient
E.
None of the above ** Answ** d
,An abstract class can contain methods with declared bodies.
A.
True
B.
False ** Answ** a
Select the order of access modifiers from least restrictive to most restrictive.
A.
public
,
private
,
protected
, default
B.
default,
protected
,
private
,
public
C.
public
, default,
protected
,
private
D.
default,
public
,
protected
,
private
E.
public
,
protected
, default,
private ** Answ** e
Which access modifier allows you to access method calls in libraries not created in
Java?
A.
public
B. static
, C. native
D. transient
E. volatile ** Answ** c
Which of the following statements are true? (Select all that apply.)
A. A final object's data cannot be changed.
B. A final class can be subclassed.
C. A final method cannot be overloaded.
D. A final object cannot be reassigned a new address in memory.
E. None of the above. ** Answ** d
The keyword extends refers to what type of relationship?
A. "is a"
B. "has a"
C. "was a"
D. "will be a"
E. None of the above ** Answ** a
Which of the following keywords is used to invoke a method in the parent class?
A. this
B. super
C. final
D. static ** Answ** b
Given the following code, what will be the outcome?
public class Funcs extends java.lang.Math {
public int add(int x, int y) {
return x + y;
}
public int sub(int x, int y) {
return x - y;
}
public static void main(String [] a) {
Funcs f = new Funcs();
System.out.println("" + f.add(1, 2));
}
}
A. The code compiles but does not output anything.
B. "3" is printed out to the console.
C. The code does not compile.
D. None of the above. ** Answ** c
Given the following code, what is the expected outcome?
public class Test {
public static void main(String [] a) {
int [] b = [1,2,3,4,5,6,7,8,9,0];