Placement Preparation Questions
Placement Preparation questions are free resources offered by mobiprep that can help you ace any company placement process. We have curated a list of the most important MCQ questions which are asked in most companies such as Infosys, TCS, Wipro, Accenture, etc. The placement preparation questions also have detailed explanations for every question ensuring you revise all the questions with detailed answers and explanations.
Q
11
With x =0, which of the following are legal lines of Java code for changing the value of x to 1? (i) x++; (ii) x= x+1; (iii) x+=1; (iv) x=+1;
a.
i, ii, & iii
b.
i & iv
c.
i, ii, iii
d.
iii & ii
Correct Answer & Explanation:
c
Operator++ increases value of variable by 1. x=x+1 can also be written in shorthand for, as x+=1. Also x=+1 will set the value of x to 1.
Q
12
How can we identify whether a compilation unit is class or interface from a .class file ?
a.
Java source file header
b.
We cannot differentiate between class and interface.
c.
Extension of compilation unit.
d.
The class or interface name should be postfixed with unit type.
Correct Answer & Explanation:
a
The Java source file contains a header that declares the type of class or interface ,its visibility with respect to other classes, its name and any superclass it may extend.
Q
13
Which of the following has highest memory requirement?
a.
Heap
b.
Stack
c.
JVM
d.
Class
Correct Answer & Explanation:
c
JVM is the super set which contains heap, stack, objects, pointers, etc.
Q
14
Which of the following statements are incorrect?
a.
Public members of class can be accessed by any code in the program
b.
Private members of class can be inherited by a subclass, and become protected members in subclass.
c.
Private members of class can only be accessed by other members of the class.
d.
Protected members of a class can be inherited by a subclass, and become private members of the subclass.
Correct Answer & Explanation:
c
Private members of a class cannot be inherited by a subclass.
Q
15
Using which of the following, multiple inheritance in Java can be implemented?
a.
Interfaces
b.
Multithreading
c.
Private methods
d.
Protected methods
Correct Answer & Explanation:
a
Multiple inheritance in java is implemented using interfaces. Multiple interfaces can be implemented by a class.
Q
16
What is the output of a Bitwise AND (&) operation if one of the inputs/operands is 0?
a.
0
b.
1
c.
0 or 1
d.
None of the above
Correct Answer & Explanation:
a
Because (0 & anything) is always equal to 0.
Q
17
What is the maximum number of ELSE-IF statements that can present in between starting IF and ending ELSE statements?
a.
32
b.
64
c.
128
d.
None of the above
Correct Answer & Explanation:
d
We can write any number of ELSE-IF statements in a Java program.
Q
18
What does AWT stand for?
a.
All Window Tools
b.
All Writing Tools
c.
Abstract Window Toolkit
d.
Abstract Writing Toolkit
Correct Answer & Explanation:
c
AWT stands for Abstract Window Toolkit, it is used by applets to interact with the user.
Q
19
Which one creates an instance of an array?
a.
int[ ] ia = new int[15];
b.
char[ ] ca = "Some String";
c.
float fa = new float[20];
d.
int ia[ ] [ ] = { 4, 5, 6 }, { 1,2,3 };
Correct Answer & Explanation:
a
It uses correct array declaration and correct array construction, while others generate a compile error.
Q
20
switch(x) { default: System.out.println("Hello"); } Which two are acceptable types for x? (i) byte (ii) long (iii) char (iv) float
a.
i & iii
b.
ii & iv
c.
i & iv
d.
ii & iii
Correct Answer & Explanation:
a
Switch statements are based on integer expressions and since both bytes and chars can implicitly be widened to an integer, these can also be used. Short is wrapper class and reference types can not be used as variables.



.png)