Q61. Given: 

What is the result? 

A. 97 98 99 100 null null null 

B. 91 98 99 100 101 102 103 

C. Compilation rails. 

D. A NullPointerException is thrown at runtime. 

E. An ArraylndexOutOfBoundsException is thrown at runtime. 

Answer:


Q62. Given: 

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 

Answer:


Q63. Which of the following will print current time? 

A. System.out.print(new LocalTime()-now0); 

B. System.out.print(new LocalTime()); 

C. System.ouLprint(LocalTime.now()); 

D. System.ouLprint(LocalTime.today()); 

E. None of the above. 

Answer:

Explanation: 

The LocalTime is an interface, so we can't use new keyword with them. So options A and C are incorrect. To get current time we can call now method on LocalTime interface. So option C is correct. Option D is incorrect as there is no method called today as in LocalTime interface 

https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html 


Q64. Given the code fragment: int[] array = {I, 2, 3, 4, 5}; And given the requirements: 

Process all the elements of the array in the order of entry. 

Process all the elements of the array in the reverse order of entry. 

Process alternating elements of the array in the order of entry. 

Which two statements are true? 

A. Requirements 1, 2, and 3 can be implemented by using the enhanced for loop. 

B. Requirements 1, 2, and 3 can be implemented by using the standard for loop. 

C. Requirements 2 and 3 CANNOT be implemented by using the standard for loop. 

D. Requirement 1 can be implemented by using the enhanced for loop. 

E. Requirement 3 CANNOT be implemented by using either the enhanced for loop or the standard for loop. 

Answer: D,E 


Q65. Which statement is true about the default constructor of a top-level class? 

A. It can take arguments. 

B. It has private access modifier in its declaration. 

C. It can be overloaded. 

D. The default constructor of a subclass always invokes the no-argument constructor of its superclass. 

Answer:

Explanation: In both Java and C#, a "default constructor" refers to a nullary constructor that is automatically generated by the compiler if no constructors have been defined for the class. The default constructor is also empty, meaning that it does nothing. A programmer-defined constructor that takes no parameters is also called a default constructor. 


Q66. Given: 

A. ns = 50 S = 125 ns = 125 S = 125 ns = 100 S = 125 

B. ns = 50 S = 125 ns = 125 S = 125 ns = 0 S = 125 

C. ns = 50 S = 50 ns = 125 S = 125 ns = 100 S = 100 

D. ns = 50 S = 50 ns = 125 S = 125 ns = 0 S = 125 

Answer:


Q67. Given the following code: 

What are the values of each element in intArr after this code has executed? 

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 

Answer:


Q68. Given: 

What is the result? 

A. simaple A 

B. Capital A 

C. simaple A default Capital A 

D. simaple A default 

E. Compilation fails. 

Answer:

Explanation: 

Here we have to use two ternary operators combined. SO first we can use to check first 

condition which is x > 10, as follows; 

x>10?">": (when condition false) Now we have to use another to check if x<10 as follows; 

x<10?V:"=" We can combine these two by putting last ternary statement in the false 

position of first ternary statement as follows; 

x>10?">":x<10?'<':"=" 

https;//docs.oraclexom/javase/tutorial/java/nutsandbolts/if.html 


Q69. Given: 

What is the output? 

A. 1Z0 

B. 1Z0-808 

C. An exception will be thrown. 

D. Compilation fails due to error at line 3. 

E. Compilation tails due to error at line 4. 

Answer:

Explanation: 

Option E is the correct answer. Code fails to compile because there is no method called concert in StringBuilder class. The concert method is in String class. Hence option E is correct Here we should have used append method of StringBuilder class, in that case option B would be correct. https://docs.oracle.com/javase/tutorial/java/data/buffers.html 


Q70. Given: 

class Base { 

// insert code here 

public class Derived extends Base{ 

public static void main(String[] args) { 

Derived obj = new Derived(); 

obj.setNum(3); 

System.out.println("Square = " + obj.getNum() * obj.getNum()); 

Which two options, when inserted independently inside class Base, ensure that the class is being properly encapsulated and allow the program to execute and print the square of the number? 

A. private int num; public int getNum() { return num; }public void setNum(int num) { this.num = num;} 

B. public int num; protected public int getNum() { return num; }protected public void setNum(int num) { this.num = num;} 

C. private int num;public int getNum() {return num;} private void setNum(int num) { this.num = num;} 

D. protected int num; public int getNum() { return num; } public void setNum(int num) { this.num = num;} 

E. protected int num; private int getNum() { return num; } public void setNum(int num) { this.num = num;} 

Answer: A,D 

Explanation: 

Incorrect: 

Not B: illegal combination of modifiers: protected and public 

not C: setNum method cannot be private. 

not E: getNum method cannot be private.