OCJA Exam: Java SE 8 Questions
OCJA Exam: Java SE 8 Questions
Vendor : Oracle
File : Premium
Questions : 223
Follow Us
Website : https://www.itmaterialstribe.com
Telegram : https://t.me/itmaterialstribe
Many Services Available, Such As Training Materials, Exam Test Practice Kits with
Updates, Vouchers and Other Exam Help Services
15C454A155523C8EF1DD59A041E20434
Exam A
QUESTION 1
Given:
A. 200.0 : 100.0
B. 400.0 : 200.0
C. 400.0 : 100.0
D. Compilation fails.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 2
Which statement is true about the switch statement?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 3
Given the code fragment:
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 4
Given the code fragment:
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.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 5
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a
15C454A155523C8EF1DD59A041E20434
class?
A. Encapsulation
B. Inheritance
C. Abstraction
D. Instantiation
E. Polymorphism
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Using the private modifier is the main way that an object encapsulates itself and hide data from the outside
world.
Reference: http://www.tutorialspoint.com/java/java_access_modifiers.htm
QUESTION 6
Given the code fragment:
Which two modifications, made independently, enable the code to compile? (Choose two.)
Correct Answer: CD
Section: (none)
Explanation
Explanation/Reference:
QUESTION 7
Given:
15C454A155523C8EF1DD59A041E20434
And given the code fragment:
A. 4W 100 Auto
4W 150 Manual
B. null 0 Auto
4W 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
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 8
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 9
Given these two classes:
15C454A155523C8EF1DD59A041E20434
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.
B.
C.
15C454A155523C8EF1DD59A041E20434
D.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 10
Given the code fragment:
A. Match 1
B. Match 2
C. No Match
D. A NullPointerException is thrown at runtime.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 11
Given:
15C454A155523C8EF1DD59A041E20434
And given the code fragment:
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 12
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. ABCD
B. ACD
C. ACDD
D. ABD
E. ABDC
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 13
Given:
Which code fragment should you use at line n1 to instantiate the dvd object successfully?
15C454A155523C8EF1DD59A041E20434
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 14
Given the code fragment:
Which option can replace xxx to enable the code to print 135?
A.
B.
C.
D.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
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
15C454A155523C8EF1DD59A041E20434
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.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 16
Given the code fragment from three files:
Which code fragment, when inserted at line 2, enables the code to compile?
15C454A155523C8EF1DD59A041E20434
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 17
Given this class:
Which three lines, when inserted independently at line n1, cause the program to print a 0 balance? (Choose
three.)
A. acct.setAmount(-acct.getAmount());
B. acct.amount = 0; <option D earlier>
C. acct.setAmount(0);
D. acct.getAmount() = 0; <option E earlier>
E. this.amount = 0; <option A earlier>
F. acct.changeAmount(0); <option F earlier>
G. acct.changeAmount(-acct.amount); <option G earlier>
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 18
Given the code fragment:
A.
B.
C.
D.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 19
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 20
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
B. At line 7, insert x --;
C. Replace line 6 with --x; and, at line 7, insert System.out.print (x);
D. Replace line 12 with return (x > 0) ? false: true;
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 21
Given the code fragment:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 22
Given the following main method:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 543210
B. 54321
C. 421
D. 5
E. Nothing is printed
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 23
Given the code fragment:
A. 100
B. 101
C. 102
D. 103
E. Compilation fails
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 24
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
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.
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 25
Given the code fragment:
Which two modifications, when made independently, enable the code to print joe:true: 100.0? (Choose
two.)
15C454A155523C8EF1DD59A041E20434
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 26
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 27
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. CBA
B. C
C. ABC
D. Compilation fails at line n1 and line n2
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 28
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 3456
B. 3436
C. 5456
D. 3646
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 29
Given the code fragment:
Which code fragment, when inserted at line 3, enables the code to print 10:20?
A.
15C454A155523C8EF1DD59A041E20434
B.
C.
D.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 30
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. A B C Work done
B. A B C D Work done
C. A Work done
D. Compilation fails
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 31
Which three are advantages of the Java exception mechanism? (Choose three.)
A. Improves the program structure because the error handling code is separated from the normal program
function
B. Provides a set of standard exceptions that covers all possible errors
C. Improves the program structure because the programmer can choose where to handle exceptions
D. Improves the program structure because exceptions must be handled in the method in which they occurred
E. Allows the creation of new exceptions that are customized to the particular program being created
Explanation/Reference:
Reference: http://javajee.com/introduction-to-exceptions-in-java
QUESTION 32
Given the code from the Greeting.Java file:
15C454A155523C8EF1DD59A041E20434
Which set of commands prints Hello Duke in the console?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 33
Given:
And:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 34
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 24
B. 0246
C. 024
D. Compilation fails
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 35
Given the code fragment:
Assume that the system date is June 20, 2014. What is the result?
A.
B.
C. Compilation fails.
D. An exception is thrown at runtime.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 36
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
Which code fragment, when inserted at line 9, enables the code to print true?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 37
Given:
A. Compilation fails.
B. false true
C. true false
D. true true
E. false false
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 38
Given the code fragment:
Which two code fragments can be independently placed at line n1 to meet the requirements? (Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 39
Given:
15C454A155523C8EF1DD59A041E20434
And given the commands:
A. Success
B. Failure
C. Compilation fails.
D. An exception is thrown at runtime
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 40
Which three statements describe the object-oriented features of the Java language? (Choose three.)
Explanation/Reference:
Reference: http://www.javaworld.com/article/2075459/java-platform/java-101--object-oriented-language-
basics--part-5--object-and-its-methods.html (see the sub title, Object is root of all classes not all other objects)
QUESTION 41
Given the following code:
15C454A155523C8EF1DD59A041E20434
What is the output?
A. 4
4
B. 3
5
C. 4
7
D. 5
4
E. 4
5
F. 4
21
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 42
You are developing a banking module. You have developed a class named ccMask that has a maskcc method.
You must ensure that the maskcc method returns a string that hides all digits of the credit card number except
the four last digits (and the hyphens that separate each group of four digits).
Which two code fragments should you use at line n1, independently, to achieve this requirement? (Choose
two.)
15C454A155523C8EF1DD59A041E20434
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: BC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 43
Given:
Acc.java:
15C454A155523C8EF1DD59A041E20434
B. Only s is accessible via obj.
C. Both r and s are accessible via obj.
D. p, r, and s are accessible via obj.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 44
Given:
A. Base
DerivedA
15C454A155523C8EF1DD59A041E20434
B. Base
DerivedB
C. DerivedB
DerivedB
D. DerivedB
DerivedA
E. A ClassCastException is thrown at runtime.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 45
Given the code fragment:
A. Execution terminates in the first catch statement, and Caught a RuntimeException is printed to the
console.
B. Execution terminates in the second catch statement, and Caught an Exception is printed to the
console.
C. A runtime error is thrown in the thread "main".
D. Execution completes normally, and Ready to use is printed to the console.
E. The code fails to compile because a throws keyword is required.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 46
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 47
Given the code fragments:
15C454A155523C8EF1DD59A041E20434
Which code fragment, when inserted at line n1, enables the code to print Hank?
A.
B.
C.
D.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 48
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. ABC
B. ABCDE
C. ABDE
D. Compilation fails.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 49
Given the code fragment:
A. true true
B. true false
C. false false
D. false true
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 50
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
Which code fragment, when inserted at line n1, enables the App class to print Equal?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 51
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
A. 1 2 3 4
followed by an ArrayIndexOutOfBoundsException
B. 1 2 3
C. 1 2 3 4
D. Compilation fails.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 52
Given the code fragment:
A. Element 0
Element 1
B. Null element 0
Null element 1
C. Null
Null
D. A NullPointerException is thrown at runtime.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 53
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 10:20
B. 0:20
C. Compilation fails at line n1
D. Compilation fails at line n2
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 54
Given the definitions of the MyString class and the Test class:
15C454A155523C8EF1DD59A041E20434
What is the result?
A.
B.
C.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 55
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
Which three lines fail to compile? (Choose three.)
A. Line 7
B. Line 8
C. Line 9
D. Line 10
E. Line 11
F. Line 12
Explanation/Reference:
QUESTION 56
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. int main 1
B. Object main 1
C. String main 1
D. Compilation fails
E. An exception is thrown at runtime
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 57
Given the code fragment:
Which option represents the state of the num array after successful completion of the outer loop?
A.
15C454A155523C8EF1DD59A041E20434
B.
C.
D.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 58
Given this code for a Planet object:
15C454A155523C8EF1DD59A041E20434
What is the output?
A.
B.
C.
D.
15C454A155523C8EF1DD59A041E20434
E.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 59
You are asked to develop a program for a shopping application, and you are given this information:
The application must contain the classes Toy, EduToy, and ConsToy. The Toy class is the superclass of the
other two classes.
The int calculatePrice (Toy t) method calculates the price of a toy.
The void printToy (Toy t) method prints the details of a toy.
Which definition of the Toy class adds a valid layer of abstraction to the class hierarchy?
A.
B.
C.
D.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 60
Given the following code:
What are the values of each element in intArr after this code has executed?
15C454A155523C8EF1DD59A041E20434
A. 15, 60, 45, 90, 75
B. 15, 90, 45, 90, 75
C. 15, 30, 75, 60, 90
D. 15, 30, 90, 60, 90
E. 15, 4, 45, 60, 90
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 61
Given this array:
Which two code fragments, independently, print each element in this array? (Choose two.)
A.
B.
C.
D.
E.
F.
Correct Answer: BE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 62
Given the content of three files:
15C454A155523C8EF1DD59A041E20434
Which statement is true?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 63
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
Which two statements are true? (Choose two.)
Correct Answer: DE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 64
Given:
A. 400 200
B. 200 200
C. 400 400
D. Compilation fails.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 65
Given the following class declarations:
public abstract class Animal
public interface Hunter
public class Cat extends Animal implements Hunter
public class Tiger extends Cat
15C454A155523C8EF1DD59A041E20434
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 66
Which statement is true about Java byte code?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
Java bytecodes help make "write once, run anywhere" possible. You can compile your program into bytecodes
on any platform that has a Java compiler. The bytecodes can then be run on any implementation of the Java
VM. That means that as long as a computer has a Java VM, the same program written in the Java
programming language can run on Windows 2000, a Solaris workstation, or on an iMac.
Reference: http://www.math.uni-hamburg.de/doc/java/tutorial/getStarted/intro/definition.html
QUESTION 67
Given:
15C454A155523C8EF1DD59A041E20434
How many MarkList instances are created in memory at runtime?
A. 1
B. 2
C. 3
D. 4
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 68
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Area is 6.0
B. Area is 3.0
C. Compilation fails at line n1
D. Compilation fails at line n2.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 69
Given the code fragment:
Which three code fragments can be independently inserted at line n1 to enable the code to print One? (Choose
three.)
A. byte x = 1;
B. short x = 1;
C. String x = "1";
D. long x = 1;
E. double x = 1;
F. Integer x = new Integer("1");
Explanation/Reference:
QUESTION 70
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. True false
B. True null
C. Compilation fails
D. A NullPointerException is thrown at runtime
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 71
Given the following code for the classes MyException and Test:
A. A
B. B
C. Either A or B
D. AB
15C454A155523C8EF1DD59A041E20434
E. A compile time error occurs at line n1
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 72
Given:
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 73
Which two are benefits of polymorphism? (Choose two.)
15C454A155523C8EF1DD59A041E20434
B. More efficient code at runtime
C. More dynamic code at runtime
D. More flexible and reusable code
E. Code that is protected from extension by other classes
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
Reference: https://www.cs.princeton.edu/courses/archive/fall98/cs441/mainus/node5.html
QUESTION 74
Given the code fragment:
A. 1:2:3:4:5:
B. 1:2:3:
C. Compilation fails.
D. An ArrayOutOfBoundsException is thrown at runtime.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 75
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. true:true
B. true:false
C. false:true
D. false:false
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 76
Given the following classes:
15C454A155523C8EF1DD59A041E20434
Which two options fail to compile when placed at line n1 of the main method? (Choose two.)
A. employee.salary = 50_000;
B. director.salary = 80_000;
C. employee.budget = 200_000;
D. manager.budget = 1_000_000;
E. manager.stockOption = 500;
F. director.stockOptions = 1_000;
Correct Answer: CE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 77
Which one of the following code examples uses valid Java syntax?
15C454A155523C8EF1DD59A041E20434
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Reference: https://docs.oracle.com/javase/tutorial/getStarted/application/
QUESTION 78
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 1324
B. 2313
C. 3142
D. 4231
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 79
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 80
Given the code fragment:
A. Answer = 0
B. Invalid calculation
C. Compilation fails only at line n1.
D. Compilation fails only at line n2.
E. Compilation fails at line n1 and line2.
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 81
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 100 200 : 0 0 :
B. 100 200 : 100 0 :
C. 100 200 : 100 200 :
D. 0 0 : 100 0 :
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 82
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. a, e
i, i
B. a, e
o, o
C. e, e
i, i
D. a, a
o, o
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 83
Given the code fragment:
A. Compilation fails.
B. 10 Hello Universe!
C. 10 Hello World!
15C454A155523C8EF1DD59A041E20434
D. 9 Hello World!
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 84
Given:
A. Compilation fails.
B. 11
C. 8
D. 9
E. 10
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 85
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 1 null
B. true false
C. false false
D. true true
E. A ClassCastException is thrown at runtime.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 86
Given the code fragment:
A. Compilation fails.
B.
C.
D.
E.
Correct Answer: E
Section: (none)
Explanation
15C454A155523C8EF1DD59A041E20434
Explanation/Reference:
Explanation:
QUESTION 87
Which statement will empty the contents of a StringBuilder variable named sb?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 88
Given:
15C454A155523C8EF1DD59A041E20434
Which code fragment can replace the if block?
A.
B.
C.
D.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 89
Given:
15C454A155523C8EF1DD59A041E20434
Which code fragment, when inserted at line 14, enables the code to print Mike Found?
A.
B.
C.
D.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 90
Which statement is true about the switch statement?
Correct Answer: D
Section: (none)
Explanation
15C454A155523C8EF1DD59A041E20434
Explanation/Reference:
Reference: http://www.dummies.com/programming/java/switch-statements-in-java/
QUESTION 91
Given:
Which two modifications enable the code to print this output? (Choose two.)
15C454A155523C8EF1DD59A041E20434
B. Replace line n1 with:
Correct Answer: AE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 92
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
A. Invalid Name
B.
C.
D.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 93
Given the code fragment:
Test.java
15C454A155523C8EF1DD59A041E20434
Which is the result?
C.
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 94
Given the code fragments:
15C454A155523C8EF1DD59A041E20434
Which modification enables the code to compile?
A.
B.
C.
15C454A155523C8EF1DD59A041E20434
D.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 95
Given:
15C454A155523C8EF1DD59A041E20434
A. A
B
B. A
C
C. C
C
D. A ClassCastException is thrown only at line n1.
E. A ClassCastException is thrown only at line n2.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 96
Given:
A.
B.
15C454A155523C8EF1DD59A041E20434
C.
D.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 97
You are asked to create a method that accepts an array of integers and returns the highest value from that
array.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 98
Which three statements are true about the structure of a Java class? (Choose three.)
15C454A155523C8EF1DD59A041E20434
B. A class can have only one private constructor.
C. A method can have the same name as a field.
D. A class can have overloaded static methods.
E. The methods are mandatory components of a class.
F. The fields need not be initialized before use.
Explanation/Reference:
QUESTION 99
Given the code fragment:
A.
B.
C.
D.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 100
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 101
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 102
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 5:5
B. 10 : 10
C. 5 : 10
D. Compilation fails.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 103
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 104
Given:
A. 10 20 30 40
B. 0 0 30 40
C. Compilation fails.
D. An exception is thrown at runtime.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 105
Which two code fragments cause a compilation error? (Choose two.)
Correct Answer: AD
Section: (none)
Explanation
Explanation/Reference:
QUESTION 106
Given:
A.
B.
15C454A155523C8EF1DD59A041E20434
C.
D.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 107
Which three statements are true about exception handling? (Choose three.)
Explanation/Reference:
QUESTION 108
Given the code fragment:
Which code fragment, inserted at line n1, prints The Top element: 30?
A.
15C454A155523C8EF1DD59A041E20434
B.
C.
D.
E.
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 109
Given the code fragment:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 110
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. false, false
B. false, true
C. true, false
D. true, true
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 111
Which two statements are true? (Choose two.)
Correct Answer: BE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 112
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Compilation fails.
B. 0 Found
C. 1 Found
D. 3 Found
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 113
Given the code fragment:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 114
15C454A155523C8EF1DD59A041E20434
Given:
A. Java SE
B. Java EE
C. Compilation fails at line n1.
D. A NullPointerException is thrown at runtime.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 115
Given this class:
15C454A155523C8EF1DD59A041E20434
Which three pieces of code, when inserted independently, set the value of amount to 100?
A.
B.
C.
D.
E.
F.
Explanation/Reference:
QUESTION 116
Given the code fragments:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: B
Section: (none)
Explanation
15C454A155523C8EF1DD59A041E20434
Explanation/Reference:
QUESTION 117
Given the code fragment:
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 118
Given:
A. 300:300
200:300
B. 300:100
200:300
C. 300:0
15C454A155523C8EF1DD59A041E20434
0:300
D. 100:300
300:200
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 119
Given:
A. C2C2
B. C1C2
C. C1C1
D. Compilation fails
15C454A155523C8EF1DD59A041E20434
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 120
Given:
Which two sets of actions, independently, enable the code fragment to print Fit?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 121
Given the code fragments:
And:
A. After line 11, three objects are eligible for garbage collection.
B. After line 11, two objects are eligible for garbage collection.
C. After line 11, one object is eligible for garbage collection.
D. After line 11, none of the objects are eligible for garbage collection.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 122
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 3
B. 4
C. -1
D. Compilation fails.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 123
Given the code fragment:
A. 2012-02-10
B. 2012-02-11
C. Compilation fails
D. A DateTimeException is thrown at runtime.
15C454A155523C8EF1DD59A041E20434
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 124
Given:
A. 10 : 30 : 6
B. 10 : 22 : 22
C. 10 : 22 : 20
D. 10 : 22 : 6
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 125
Given:
15C454A155523C8EF1DD59A041E20434
And given the code fragment:
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 126
Given this class:
15C454A155523C8EF1DD59A041E20434
Which two changes would encapsulate this class and ensure that the area field is always equal to length *
height whenever the Rectangle class is used?
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 127
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 128
Given the code fragment:
Which three code fragments are valid at line n1? (Choose three.)
A.
B.
C.
D.
E.
Explanation/Reference:
QUESTION 129
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Compilation fails.
B. 35
C. 00
D. 9 25
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 130
Given the code fragment:
Which two code fragments can be independently inserted at line n1 to enable the code to print the elements of
the array in reverse order? (Choose two.)
15C454A155523C8EF1DD59A041E20434
A.
B.
C.
D.
E.
Correct Answer: AE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 131
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 10 Hello Hello 11
B. 10 Hello Hello 121
C. 100 Hello 121
D. 100 Hello Hello 121
E. 10 Hello 11
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
QUESTION 132
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Compilation fails.
B. Hi removed
C. An UnsupportedOperationException is thrown at runtime.
D. The program compiles, but it prints nothing.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 133
Which two class definitions fail to compile? (Choose two.)
A.
B.
C.
D.
15C454A155523C8EF1DD59A041E20434
E.
Correct Answer: CD
Section: (none)
Explanation
Explanation/Reference:
QUESTION 134
Given:
A. null
Richard
Donald
B. Richard
Donald
C. Compilation fails.
D. An ArrayIndexOutOfBoundsException is thrown at runtime.
E. A NullPointerException is thrown at runtime.
Correct Answer: E
Section: (none)
Explanation
15C454A155523C8EF1DD59A041E20434
Explanation/Reference:
QUESTION 135
This grid shows the state of a 2D array:
Which line of code, when inserted in place of //line n1, adds an X into the grid so that the grid contains three
consecutive XS?
A. grid[2][1] = ‘X’;
B. grid[3][2] = ‘X’;
C. grid[3][1] = ‘X’;
D. grid[2][3] = ‘X’;
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 136
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 137
Given the code snippet from a compiled Java source file:
Which command-line arguments should you pass to the program to obtain the following output?
Arg is 2
A. java MyFile 1 3 2 2
B. java MyFile 2 2 2
C. java MyFile 1 2 2 3 4
D. java MyFile 0 1 2 3
15C454A155523C8EF1DD59A041E20434
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 138
Given the code fragment:
Which two modifications should you make so that the code compiles successfully? (Choose two.)
Correct Answer: CE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 139
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 1 3 5 7
13
B. 1 3
13
C. 1 3
1300
D. 1 3
followed by an ArrayIndexOutOfBoundsException
E. Compilation fails.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 140
Given:
MainTest.java:
15C454A155523C8EF1DD59A041E20434
and commands:
A. String main 1
B. An exception is thrown at runtime
C. String main 1 2 3
D. String main 123
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 141
Which two statements are true about Java byte code? (Choose two.)
Correct Answer: AE
Section: (none)
Explanation
Explanation/Reference:
QUESTION 142
Which is true about the switch statement?
Correct Answer: B
Section: (none)
Explanation
15C454A155523C8EF1DD59A041E20434
Explanation/Reference:
Reference: https://www.geeksforgeeks.org/switch-statement-in-java/
QUESTION 143
Given the code fragment:
A. 3142
B. 2413
C. 1324
D. 4231
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 144
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 95
B. 81 25
C. Compilation fails.
D. 00
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 145
Given this segment of code:
15C454A155523C8EF1DD59A041E20434
Which two statements, if either were true, would make the code compile? (Choose two.)
Correct Answer: BC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 146
Given the code fragments:
15C454A155523C8EF1DD59A041E20434
C. Tool::export
Tool::export
D. Compilation fails at both line n1 and line2.
E. RTool::export
Tool::export
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 147
Given:
15C454A155523C8EF1DD59A041E20434
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 148
Given the code fragment:
A. 2012-02-10 00:00
B. 2012-01-30
C. 2012-02-10
D. A DateTimeException is thrown at runtime.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 149
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 150
Given the code snippet from a compiled Java source file:
15C454A155523C8EF1DD59A041E20434
Which command should you run to obtain this output?
A. java MyFile 2
B. java MyFile 1 2 3 4
C. java MyFile 1 2 2
D. java MyFile 2 2
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 151
Given the code fragment:
A. A B C Work done
B. A B C D Work done
C. A Work done
D. Compilation fails
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 152
Given the code fragment:
A. 3
B. 0
C. Compilation fails.
D. -1
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 153
Given the code fragment:
A. Compilation fails.
B. The program compiles, but it prints nothing.
C. HiHowAreYou removed
D. An UnsupportedOperationException is thrown at runtime.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 154
Given the code fragment:
A. A
B
B. A element 0
B element 1
C. A NullPointerException is thrown at runtime.
D. A 0
B1
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 155
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. C B A
B. C
C. A B C
D. Compilation fails at line n1 and line n2
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 156
Given this code for the classes MyException and Test:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. A
B. AB
C. A compile time error occurs at line n1.
D. B
E. I
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 157
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A.
B.
C. Invalid Name
D.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 158
Which three statements are true about the structure of a Java class? (Choose three.)
15C454A155523C8EF1DD59A041E20434
F. Methods and fields are optional components of a class.
Explanation/Reference:
QUESTION 159
Given the code fragment:
Correct Answer: AC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 160
Given these classes:
15C454A155523C8EF1DD59A041E20434
and this main method:
Which two options compile when placed at line n1 of the main method? (Choose two.)
A. director.stockOptions = 1_000;
B. employee.salary = 50_000;
C. manager.budget = 1_000_000;
D. manager.stockOption = 500;
E. employee.budget = 200_000;
F. director.salary = 80_000;
Correct Answer: BF
Section: (none)
Explanation
Explanation/Reference:
QUESTION 161
Given:
15C454A155523C8EF1DD59A041E20434
A. Welcome Visit Count:0
Welcome Visit Count: 1
B. Compilation fails at line n2.
C. Compilation fails at line n1.
D. Welcome Visit Count:0
Welcome Visit Count: 0
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 162
Given:
15C454A155523C8EF1DD59A041E20434
A. C1C2
B. C1C1
C. Compilation fails.
D. C2C2
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 163
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 24
B. 0246
C. 024
D. Compilation fails.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 164
Given:
15C454A155523C8EF1DD59A041E20434
A. 3456
B. 3436
C. 5456
D. 3656
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 165
Given the code fragment:
Correct Answer: BC
Section: (none)
Explanation
Explanation/Reference:
QUESTION 166
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A.
B.
C.
D.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 167
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 97 98
99 100 null null null
B. 97 98
99 100 101 102 103
C. Compilation fails.
D. A NullPointerException is thrown at runtime.
E. An ArraylndexOutOfBoundsException is thrown at runtime.
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 168
Given the code fragment:
Which code fragment, when inserted at line n1, enables the App class to print Equal?
A. Option A
B. Option B
C. Option C
D. Option D
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 169
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. ABC
B. ABCDE
C. ABDE
D. Compilation fails.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 170
Given the code fragment:
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 171
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
Test.java:
C.
15C454A155523C8EF1DD59A041E20434
D. Compilation fails in the Test class.
E. Both the Employee class and the Test class fail to compile.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 172
Given:
A.
B.
C.
D.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 173
Given the code fragment:
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 174
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. A
B
B. A
C
C. C
C
D. A ClassCastException is thrown only at line n1.
E. A ClassCastException is thrown only at line n2.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 175
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
Which option represents the state of the num array after successful completion of the outer loop?
A.
B.
C.
D.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 176
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Answer = 0
B. Invalid calculation
C. Compilation fails only at line n1.
D. Compilation fails only at line n2.
E. Compilation fails at line n1 and line2.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 177
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Base
DerivedA
B. Base
DerivedB
C. DerivedB
DerivedB
D. DerivedB
DerivedA
E. A ClassCastException is thrown at runtime.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 178
Given the definitions of the MyString class and the Test class:
A.
B.
C.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
QUESTION 179
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Compilation fails.
B. false true
C. true false
D. true true
E. false false
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 180
Given the code fragments:
And:
15C454A155523C8EF1DD59A041E20434
Which statement is true?
A. After line 11, three objects are eligible for garbage collection.
B. After line 11, two objects are eligible for garbage collection.
C. After line 11, one object is eligible for garbage collection.
D. After line 11, none of the objects are eligible for garbage collection.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 181
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. ABCD
B. ACD
C. ACDD
D. ABCC
E. ABDC
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 182
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
Which action enables it to print AB?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 183
Given the definitions of the Bird class and the Peacock class:
15C454A155523C8EF1DD59A041E20434
Which code snippet can be inserted to print Fly.Dance. ?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
QUESTION 184
Given the code fragment:
A.
B.
15C454A155523C8EF1DD59A041E20434
C.
D.
E.
Correct Answer: E
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 185
Given the code fragment:
A. 11
15C454A155523C8EF1DD59A041E20434
B. 10
C. 12
D. A compile time error occurs.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 186
Given the code fragment:
A. 2 : 7 : 3
B. 7 : 7 : 9
C. 2 : 7 : 0
D. 7 : 2 : 3
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 187
Given:
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 188
Given the code fragment:
A. 1 2 3 0 0
1 2 3 0 0
B. An Exception is thrown at run time.
C. 1 2 3 0 0
1 2 3
D. 1 2 3
1 2 3
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 189
Examine:
15C454A155523C8EF1DD59A041E20434
Which statement is true?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 190
Given the code fragment:
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 191
Given:
And:
15C454A155523C8EF1DD59A041E20434
A. ns = 100 s =125
ns = 0 s = 125
ns = 125 s = 125
B. ns = 50 s = 50
ns = 125 s = 125
ns = 0 s = 125
C. ns = 50 s = 125
ns = 125 s = 125
ns = 0 s = 125
D. ns = 50 s = 50
ns = 125 s =125
ns = 100 s =100
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 192
Which two array initialization statements are valid? (Choose two.)
Correct Answer: BE
Section: (none)
Explanation
Explanation/Reference:
Reference: https://stackoverflow.com/questions/1200621/how-do-i-declare-and-initialize-an-array-in-java
QUESTION 193
Given the class definitions:
class C1 {}
class C2 extends C1 {}
class C3 extends C2 {}
A. line 18
15C454A155523C8EF1DD59A041E20434
B. line 17
C. line 19
D. line 16
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 194
Which two features can be implemented in a Java application by encapsulating the entity classes used?
(Choose two.)
A. data validation
B. compile time polymorphism
C. data hiding
D. data abstraction
E. data memory optimization
Correct Answer: CD
Section: (none)
Explanation
Explanation/Reference:
Reference: https://www.geeksforgeeks.org/encapsulation-in-java/
QUESTION 195
Given the code fragment:
Correct Answer: B
Section: (none)
Explanation
15C454A155523C8EF1DD59A041E20434
Explanation/Reference:
Explanation:
QUESTION 196
Given the code fragment:
A. [JavaForum, ExpertForum]
B. [JavaGroup, ExpertGroup]
C. [JavaForumGroup, ExpertForumGroup]
D. [JavaGroup, TechGroup ExpertGroup]
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 197
Given the code fragment:
A.
15C454A155523C8EF1DD59A041E20434
B.
C.
D.
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
QUESTION 198
Which two initialization statements are valid? (Choose two.)
Correct Answer: CD
Section: (none)
Explanation
Explanation/Reference:
Reference: http://www.functionx.com/java/Lesson06.htm
QUESTION 199
Examine the given definitions:
15C454A155523C8EF1DD59A041E20434
and the code fragment:
Which statement is true about the implementation of Object-Oriented Programming concepts in the given
code?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 200
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. true
B. false
C. -1
D. 0
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 201
Given the code fragment:
15C454A155523C8EF1DD59A041E20434
Sold: 5 items. Stock in Hand: 5
Purchased: 5 items. Stock in Hand: 10?
A. Declare the stock variable and the purchase(), sell(), and printStock() methods static.
B. Declare the stock variable and the printStock() method static.
C. Declare the stock and qty variables and the printStock() method static.
D. Declare the stock variable static.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 202
Given:
A. Child 10
Child 100
Parent 100
B. Parent 10
Child 10
15C454A155523C8EF1DD59A041E20434
Parent 1000
C. Child 10
Parent 100
Parent 100
D. A compile time error occurs.
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 203
Given the code fragment:
A. EN FR JP
B. EN FR
C. CH
D. EN FR CH
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 204
Given:
A. Vehicle
Bus
B. Bus
Vehicle
15C454A155523C8EF1DD59A041E20434
C. Bus
D. The program doesn’t print anything
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 205
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. true:false:true
B. false:true:true
C. false:true:false
D. true:true:false
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 206
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. Good Luck!
B. Good Day!
C. Welcome!
D. Hello!
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 207
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. AC
B. BD
C. BC
D. AD
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 208
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. 10
20
B. A compile time error occurs
C. 20
20
D. 10
10
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 209
Given:
15C454A155523C8EF1DD59A041E20434
Which statement is true?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 210
Which statement is true about the main() method?
A. It is invoked by JRE
B. It is a final method
C. It returns true if it is executed successfully at run time
D. It must be defined within a public class
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Reference: https://www.quora.com/How-does-a-main-method-get-invoked-automatically-explain-it-in-brief
QUESTION 211
Given the code fragment:
A. S 6
B. S 5
15C454A155523C8EF1DD59A041E20434
C. s-1
D. w 7
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 212
Given the code fragment:
A.
B.
C.
15C454A155523C8EF1DD59A041E20434
D.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 213
Given these requirements:
Bus and Boat are Vehicle type classes.
The start() and stop() methods perform common operations across the Vehicle class type.
The ride() method performs a unique operations for each type of Vehicle.
A. 1. Create an abstract class Vehicle by defining start() and stop() methods, and declaring the ride()
abstract method.
2. Create Bus and Boat classes by inheriting the Vehicle class and overriding the ride() method.
B. 1. Create an interface Vehicle by defining start() and stop() methods, and declaring the ride()
abstract method.
2. Create Bus and Boat classes by implementing the Vehicle class.
C. 1. Create an abstract class Vehicle by declaring stop(), start(), and ride() abstract methods.
2. Create Bus and Boat classes by inheriting the Vehicle class and overriding all the methods.
D. 1. Create an interface Vehicle by defining default stop(), start(), and ride() methods.
2. Create Bus and Boat classes by implementing the Vehicle interface and overriding the ride() method.
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
15C454A155523C8EF1DD59A041E20434
QUESTION 214
Given:
A. null:null:0.0
B. null:null
C. <<HashCode>>:0.0
D. null:0.0
Correct Answer: D
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 215
Given:
A. 0:0
100:0
B. null:0
15C454A155523C8EF1DD59A041E20434
100:0
C. 0:0
100:200
D. null:null
100:null
Correct Answer: A
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 216
Given:
Correct Answer: AD
15C454A155523C8EF1DD59A041E20434
Section: (none)
Explanation
Explanation/Reference:
QUESTION 217
Examine the content of App.java:
Which is true?
A. The App.class file is stored within the p1 folder. The Test.class file is stored within the p2 sub-folder
of p1.
B. The App class is accessible within the Test class without an import statement.
C. import p1.App; is used to access the App class within the Test class.
D. It is optional to have the package statement as the first line of class definitions.
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
QUESTION 218
Given the code fragment:
A. Boolean s = p.apply(101);
System.out.println(s);
15C454A155523C8EF1DD59A041E20434
B. Boolean s = p.test(100);
System.out.println(s);
C.
D. System.out.println(p.apply(100));
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 219
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: B
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 220
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
A. c=null
b=true
f=0.0
B. c=
b=false
f=0.0
C. c=null
b=false
f=0.0
D. c=0
b=false
f=0.0F
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
QUESTION 221
Which two code fragments cause compilation errors? (Choose two.)
A. double y1 = 203.22;
float fit = y1;
B. float fit = (float) 1_11.00;
C. Float fit = 100.00;
D. int y2 = 100;
float fit = (float) y2;
15C454A155523C8EF1DD59A041E20434
E. float fit = 100.00F;
Correct Answer: BD
Section: (none)
Explanation
Explanation/Reference:
QUESTION 222
Given the code fragment:
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434
QUESTION 223
Given:
15C454A155523C8EF1DD59A041E20434
What is the result?
Correct Answer: C
Section: (none)
Explanation
Explanation/Reference:
Explanation:
15C454A155523C8EF1DD59A041E20434