
Question 1
Answer
Question 1
What will be the output of the above program?
a) 32445668
b) 32446687
c) 324456687
d) 32456687
Answer
Question 2
Answer
Question 2
Which is true about the classes described above?
a) Class A tightly encapsulated
b) Class B is tightly encapsulated
c) Class A and B both are tightly encapsulated
d) Neither Class A nor class B both is tightly encapsulated
Answer
Question 3
Answer
Question 3
What is the result of the above code?
a) Compilation fails since a catch block is not present.
b) Prints only “f” in the output.
c) Only a runtime error is displayed.
d) Prints an “f” in the output and a runtime error is also displayed.
Answer
Question 4
Answer
Question 4
Say that class Rodent has a child class Rat and another child class Mouse.
Class Mouse has a child class PocketMouse. Examine the following:
Rodent rod;
Rat rat = new Rat();
Mouse mos = new Mouse();
PocketMouse pkt = new PocketMouse();
Which of the following will cause a compile error?
a) rod = rat;
b) rod = mos;
c) pkt = null;
d) okt = rat;
Answer
Question 5
Answer
Question 5
What is the result of the above code?
a) x = 14
b) x = 21
c) Compilation fails at line 2
d) Compilation fails at line 14
Answer
Also Checkout: TCS NQT Sample Question Paper
Question 6
Answer
Question 6
What will be the output on executing the above code?
a) 0
b) 110
c) 1001
d) 1111
Answer
Question 7
Answer
Question 7
Which statement is true for the above code?
a) The code will fail to compile.
b) The use of aggregation is justified. Since Planet has-a Star.
c) The code will fail to compile if the name starName is replaced with
d) An instance of Planet is a valid instance of a HeavenlyBody.
Answer
Question 8
Answer
Question 8
What is the expected behavious?
a) Print “Invoking calculate…”
b) Runtime error occurs
c) Compilation error at line 2
d) Compilation error at line 14
Answer
Question 9
Answer
Question 9
What is the result of attempting to compile and run the program?
a) Prints true,true,true
b) prints false,false,true
c) prints false,null,true
d) compile time error
Answer
C) 0.1
Also Checkout