Q101. 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 

Answer:


Q102. Given: 

What is the result? 

A. hEllOjAvA! 

B. Hello java! 

C. Out of limits hEllOjAvA! 

D. Out of limits 

Answer:


Q103. Given the code fragment: 

Which two modifications, when made independently, enable the code to print joe:true: 100.0? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

Answer: A,C 


Q104. Given the code fragment: 

System.out.println(2 + 4 * 9 - 3); //Line 21 

System.out.println((2 + 4) * 9 - 3); // Line 22 

System.out.println(2 + (4 * 9) - 3); // Line 23 

System.out.println(2 + 4 * (9 - 3)); // Line 24 

System.out.println((2 + 4 * 9) - 3); // Line 25 

Which line of codes prints the highest number? 

A. Line 21 

B. Line 22 

C. Line 23 

D. Line 24 

E. Line 25 

Answer:

Explanation: The following is printed: 35 51 

35 

26 

35 


Q105. Given: 

What is result? 

A. Successful 

B. Unsuccessful 

C. Compilation fails 

D. An exception is thrown at runtime 

Answer:


Q106. Given the code fragment: 

And given the requirements: 

. If the value of the qty variable is greater than or equal to 90, discount = 0.5 

. If the value of the qty variable is between 80 and 90, discount = 0.2 

Which two code fragments can be independently placed at line n1 to meet the requirements? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

Answer: A,C 


Q107. Given: 

public class Test { 

static boolean bVar; 

public static void main(String[] args) { 

boolean bVar1 = true; 

int count =8; 

do { 

System.out.println("Hello Java! " +count); 

if (count >= 7) { 

bVar1 = false; 

} while (bVar != bVar1 && count > 4); 

count -= 2; 

What is the result? 

A. Hello Java! 8 Hello Java! 6 Hello Java! 4 

B. Hello Java! 8 Hello Java! 6 

C. Hello Java! 8 

D. Compilation fails 

Answer:

Explanation: Hello Java! 8 


Q108. Given: 

A. Ym Xm2 

B. Ym Xm1 

C. Compilation fails 

D. A ClassCastException is thrown at runtime 

Answer:


Q109. Given: 

What is the result? 

A. 120 

B. 120D 

C. A NumberFormatException will be thrown. 

D. Compilation fails due to error at line 5. 

E. Compilation tails due to error at line 8. 

Answer:

Explanation: 

At line 5, we have created a wrapper object of double by passing 120D, which is convertible to a Double, so there won't be any exception there. But if you check carefully, you can see the variable number is declared inside try block, so the scope of the variable number is limited to that block, so trying to access it outside causes a compile time error. httpsy/docs.oracle.com/javase/tutorial/iava/nutsandbolts/variables.html 


Q110. Given: 

And the commands: 

Javac Test.java 

Java Test 12345 

What is the result? 

A. Number us : 12345 

B. A NullPointerException is thrown at runtime 

C. A NumberFormatException is thrown at runtime 

D. AnArrayIndexOutOfBoundException is thrown at runtime. 

Answer: