top of page
  • Facebook
  • Twitter
  • Instagram

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

21

What is the numerical range of char?

a.

0 to 32767

b.

0 to 65535

c.

-256 to 255

d.

-32768 to 32767

Correct Answer & Explanation:

b

The char type is integral but unsigned. The range of a variable of type char is from 0 to 65535. Java characters are Unicode, which is a 16-bit encoding capable of representing a wide range of international characters.

Q

22

Which of these method of ArrayList class is used to obtain present size of an object?

a.

size()

b.

length()

c.

index()

d.

capacity()

Correct Answer & Explanation:

a

Q

23

How can we remove an object from ArrayList?

a.

remove() method

b.

using iterator

c.

remove () method and using iterator

d.

delete() method

Correct Answer & Explanation:

c

There are two ways to remove an object from ArrayList. We can use overloaded method remove(int index) or remove(Object obj). We can also use as an iterator to remove the object.

Q

24

Which of the following keywords is used for throwing exception manually?

a.

finally

b.

try

c.

throw

d.

catch

Correct Answer & Explanation:

c

”throw” keyword is used for throwing exception manually in java program. User defined exceptions can be thrown too.

Q

25

Which component is responsible to optimize bytecode to machine code?

a.

JVM

b.

JDK

c.

JIT

d.

JRE

Correct Answer & Explanation:

c

JIT optimizes bytecode to machine specific language code by compiling similar bytecodes at same time. This reduces overall time taken for compilation of bytecode to machine specific language.

Q

26

Which of the following options is the best for generating random integer 0 or 1?

a.

(int)Math.random()

b.

(int)Math.random()+1

c.

(int)(Math.random()+0.5)

d.

(int)(Math.random()+0.2)

Correct Answer & Explanation:

c

random() is a static method defined in Math class. Syntax: static double random()
random() always returns a value in the range 0.0 1 to 1.99 that will be '1' when typecasted to int. not selected.

Q

27

What will be the output of the program? public class Test { public static void main(String [] args) { signed int x = 10; for (int y=0; y<5; y++, x--) System.out.print(x + ", "); } }

a.

b.

9,8,7,6,5

c.

Compilation fails

d.

An exception is thrown at runtime

Correct Answer & Explanation:

c

The word "signed" is not a valid modifier keyword in the Java language. All number primitives in Java are signed. Hence the Compilation will fail.

Q

28

Which two of the following methods are defined in class Thread? (i) start() (ii) wait() (iii)notify() iv)run() v)terminate()

a.

i & iv

b.

ii & iii

c.

iii & iv

d.

ii & iv

Correct Answer & Explanation:

a

i & iv because only start() and run() are defined by the Thread class.

Q

29

Which is true about a method-local inner class?

a.

It must be marked final.

b.

It can be marked abstract.

c.

It can be marked public.

d.

It can be marked static.

Correct Answer & Explanation:

b

Because a method-local inner class can be abstract, although it means a subclass of the inner class must be created if the abstract class is to be used (so an abstract method-local inner class is probably not useful).

Q

30

Which of these keywords can be used to prevent method overriding?

a.

Static

b.

Constant

c.

Protected

d.

Final

Correct Answer & Explanation:

d

To disallow a method from being overridden specify final as a modifier at the start of its declaration.

bottom of page