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
1
A process in OOP concept that involves recognizing and focusing on the important characteristics of a situation or object is known as:
a.
Abstraction
b.
Polymorphism
c.
Encapsulation
d.
Inheritance
Correct Answer & Explanation:
a
Abstraction is a process of hiding the implementation details from the user. In other words, the user will have the information on what the object does instead of how it does it.
Q
2
In Java, ‘char’ allocates how many bits?
a.
16
b.
8
c.
32
d.
64
Correct Answer & Explanation:
a
Java uses Unicode system not ASCII code system and to represent Unicode system 8 bit is not enough to represent all characters, so java uses 2 byte for characters.
Q
3
Which one of these is a valid method declaration?
a.
void method1
b.
void method2()
c.
void method3(void)
d.
method4()
Correct Answer & Explanation:
b
In Java, a method is declared with return type and is represented by parentheses.
Q
4
Which of these operators is used to allocate memory for an object?
a.
malloc
b.
alloc
c.
give
d.
new
Correct Answer & Explanation:
d
Operator new dynamically allocates memory for an object and returns a reference to it. This reference is address in memory of the object allocated by new.
Q
5
Which of these methods is used to explicitly set the priority of a thread?
a.
set()
b.
make()
c.
setPriority()
d.
makePriority()
Correct Answer & Explanation:
c
The default value of priority given to a thread is 5 but we can explicitly change that value between the permitted values 1 & 10, using the method setPriority().
Q
6
What is the output of the Java code snippet with a ternary operator? String name = "java"; int marks = name == "java"?10:20; System.out.println("Marks=" + marks);
a.
Marks=0
b.
Marks=10
c.
Marks=20
d.
Compile error
Correct Answer & Explanation:
b
Because name ==”java” is the correct statement that’s why the expression just after the ternary operator is printed.
Q
7
Which of the following would compile without error?
a.
int a = Math.abs(-5);
b.
int b = Math.abs(5.0);
c.
int c = Math.abs(5.5F);
d.
int d = Math.abs(5L);
Correct Answer & Explanation:
a
The return value of the Math.abs() method is always the same as the type of the parameter passed into that method.
Q
8
What do you mean by javap?
a.
Java Compiler
b.
Java Disassembler
c.
Java Debugger
d.
Java Interpreter
Correct Answer & Explanation:
b
javap command or Java Disassembler disassembles one or more class files.
It is used to get the information of any class or interface.
Q
9
In Java, byte, short, int and long are
a.
Unsigned
b.
Signed
c.
None of these
d.
Both a) and b)
Correct Answer & Explanation:
a
Signed data means the data has to be declared before we use it and thus these datatypes are signed .Only String is unsigned.
Q
10
Which of the following is false about arrays on Java?
a.
A java array is always an object.
b.
Arrays in Java are always allocated on heap.
c.
Length of array can be changed after creation of array.
d.
None of the above
Correct Answer & Explanation:
c
In Java, arrays are objects, they have members like length. The length member is final and cannot be changed. All objects are allocated on heap in Java, so arrays are also allocated on heap.