Page 1 out of 13. Viewing questions 1-15 out of 190
Question 1
Given: What is the result?
A.
200.0 : 100.0
B.
400.0 : 200.0
C.
400.0 : 100.0
D.
Compilation fails.
Answer:
C
User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 2
Which statement is true about the switch statement?
A.
It must contain the default section.
B.
The break statement, at the end of each case block, is optional.
C.
Its case label literals can be changed at runtime.
D.
Its expression must evaluate to a collection of values.
Answer:
B
User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 3
Given the code fragment: What is the result?
A.
May 04, 2014T00:00:00.000
B.
2014-05-04T00:00: 00.000
C.
5/4/14T00:00:00.000
D.
An exception is thrown at runtime.
Answer:
D
User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 4
Given the code fragment: What is the result?
A.
Sum is 600
B.
Compilation fails at line n1.
C.
Compilation fails at line n2.
D.
A ClassCastException is thrown at line n1.
E.
A ClassCastException is thrown at line n2.
Answer:
C
User Votes:
A
50%
B
50%
C
50%
D
50%
E
50%
Discussions
0/ 1000
Question 5
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?
A.
Encapsulation
B.
Inheritance
C.
Abstraction
D.
Instantiation
E.
Polymorphism
Answer:
A
Explanation: Using the private modifier is the main way that an object encapsulates itself and hide data from the outside world. References:
User Votes:
A
50%
B
50%
C
50%
D
50%
E
50%
Discussions
0/ 1000
Question 6
Given the code fragment: Which two modifications, made independently, enable the code to compile? (Choose two.)
A.
Make the method at line n1 public.
B.
Make the method at line n2 public.
C.
Make the method at line n3 public.
D.
Make the method at line n3 protected.
E.
Make the method at line n4 public.
Answer:
C,D
User Votes:
A
50%
B
50%
C
50%
D
50%
E
50%
Discussions
0/ 1000
Question 7
Given: And given the code fragment: What is the result?
A.
4W 100 Auto4W 150 Manual
B.
null 0 Auto4W 150 Manual
C.
Compilation fails only at line n1
D.
Compilation fails only at line n2
E.
Compilation fails at both line n1 and line n2
Answer:
E
User Votes:
A
50%
B
50%
C
50%
D
50%
E
50%
Discussions
0/ 1000
Question 8
Given: What is the result?
A.
Compilation fails at line n1.
B.
InitializedStartedInitialized
C.
InitializedStarted
D.
Compilation fails at line n2.
Answer:
D
User Votes:
A 1 votes
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 9
Given these two classes: Any amount of electricity used by a customer (represented by an instance of the Customer class) must contribute to the customer's bill (represented by the member variable bill) through the useElectricity method. An instance of the Customer class should never be able to tamper with or decrease the value of the member variable bill. How should you write methods in the ElectricAccount class at line n1 so that the member variable bill is always equal to the value of the member variable kwh multiplied by the member variable rate?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer:
A
User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 10
Given the code fragment: What is the result?
A.
Match 1
B.
Match 2
C.
No Match
D.
A NullPointerException is thrown at runtime.
Answer:
A
User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 11
Given: And given the code fragment: Book book1 = new EBook(); book1.readBook();
Which option enables the code to compile?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer:
D
User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 12
Given: What is the result?
A.
A B C D
B.
A C D
C.
A C D D
D.
A B D
E.
A B D C
Answer:
C
User Votes:
A
50%
B
50%
C
50%
D
50%
E
50%
Discussions
0/ 1000
Question 13
Given: Which code fragment should you use at line n1 to instantiate the dvd object successfully?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer:
C
User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 14
Given the code fragment: Which option can replace xxx to enable the code to print 135?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Answer:
B
User Votes:
A
50%
B
50%
C
50%
D
50%
Discussions
0/ 1000
Question 15
Which statement best describes encapsulation?
A.
Encapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects.
B.
Encapsulation ensures that classes can be designed so that their methods are inheritable.
C.
Encapsulation ensures that classes can be designed with some fields and methods declared as abstract.
D.
Encapsulation ensures that classes can be designed so that if a method has an argument MyType x, any subclass of MyType can be passed to that method.