![](https://sp-ao.shortpixel.ai/client/to_webp,q_glossy,ret_img,w_1331,h_445/https://codewindow.in/wp-content/uploads/2021/11/Deloitte.png)
Question 1
Answer
Question 1
What is true about the package statement in java?
a) It can appear anywhere in the file as long as the syntax is correct.
b) It should appear after all the import statements but before the class.
c) There can be more than one package statement.
d) It should be the first non-comment line in the java source file.
Answer
Question 2
Answer
Question 2
What type parameter must the following method be called with?
int myMethod(double[] ar)
{
…
}
a) An empty double array.
b) A reference to an array that contains elements of type double.
c) A reference to an array that contain zero or more elements of type int.
d) An array of any length that contains double and must be named ar.
Answer
Question 3
Answer
Question 3
What restriction is there on using the super reference in a construction?
a) It can only be used in the parent’s constructor.
b) Only one child class can use it.
c) It must be used in the last statement of the constructor.
d) It must be used in the first statement of the constructor.
Answer
Question 4
Answer
Question 4
What type of exception is throw by parseInt() if it gets illegal data?
a) ArithmeticException
b) RunTimeException
c) NumberFormatException
d) NumberError
Answer
Question 5
Answer
Question 5
Which of the following is an illegal declaration of array?
a) int[] myscore[];
b) char[] mychars;
c) Dog mydogs[7];
d) Dog mydogs[];
Answer
Also Checkout: TCS NQT Sample Question Paper
Question 6
Answer
Question 6
Which is valid declaration within an interface?
a) protected short stop=23;
b) final void madness(short stop);
c) public Boolean madness(long bow);
d) static char madness(double duty);
Answer
Question 7
Answer
Question 7
Which statement is true about interfaces?
a) Interfaces allow multiple implementation inheritance.
b) Interfaces can extends any number of interfaces.
c) Member of an interface are never static.
d) Member of an interface can always be declared ststic.
Answer
Question 8
Answer
Question 8
Here is an abstract method defined in the parent.
public abstract int sumUp(int[] arr);
Which of the following is required in a non-abstract child?
a) public abstract int sumUp(int[] arr){…}
b) public int sumUp(int[] arr){…}
a) public double sumUp(int[] arr){…}
a) public int sumUp(long[] arr){…}
Answer
Question 9
Answer
Question 9
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
Also Checkout