Top 40 Java Placement MCQ Questions and Answers

Updated: Jun 15

Java is an adaptable language, letting developers to build programmes that would run on any system, independent of architecture or platform. According to the Java home page, Java is used by over 1 billion PCs and 3 billion mobile phones globally. Top Tech companies including Amazon, Twitter uses Java in its back- end. Getting a good grasp of top Java Placement MCQ Questions will surely provide you an edge in cracking such top companies.

 

Top Java Placement MCQ Questions PDF

Mobiprep handbooks are free downloadable placement preparation resources that can help you ace any company placement process. We have curated a list of the 40 most important Java MCQ questions with detailed explanations to ensure the best placement preparation.

Top 40 Java Interview Questions and Answers
.pdf
Download PDF • 742KB




 

These top Java Placement questions have been segmented into three sections:

Basic Java Placement Questions


Q 1. A process in OOP concept that involves recognizing and focusing on the important characteristics of a situation or object is known as:

  • Abstraction

  • Polymorphism

  • Encapsulation

  • Inheritance

Correct Answer: A Explanation: 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.


Q2. In Java, ‘char’ allocates how many bits?

  • 16

  • 8

  • 32

  • 64

Q 3. Which one of these is a valid method declaration?

  • void method1

  • void method2()

  • void method3(void)

  • method4()

Q 4. Which of these operators is used to allocate memory for an object?

  • malloc

  • alloc

  • give

  • new

Q 5. Which of these methods is used to explicitly set the priority of a thread?

  • set()

  • make()

  • setPriority()

  • makePriority()

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);

  • Marks=0

  • Marks=10

  • Marks=20

  • Compile error

Q 7. Which of the following would compile without error?

  • int a = Math.abs(-5);

  • int b = Math.abs(5.0);

  • int c = Math.abs(5.5F);

  • int d = Math.abs(5L);

Q 8. What do you mean by javap?

  • Java Compiler

  • Java Disassembler

  • Java Debugger

  • Java Interpreter

Q 9. In Java, byte, short, int and long are

  • Unsigned

  • Signed

  • None of these

  • Both a) and b)

Q 10. Which of the following is false about arrays on Java?

  • A java array is always an object.

  • Arrays in Java are always allocated on heap.

  • Length of array can be changed after creation of array.

  • None of the above

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;

  • i, ii, & iii

  • i & iv

  • i, ii, iii

  • iii & ii

Q 12. How can we identify whether a compilation unit is class or interface from a .class file ?

  • Java source file header

  • We cannot differentiate between class and interface.

  • Extension of compilation unit.

  • The class or interface name should be postfixed with unit type.

Q 13. Which of the following has highest memory requirement?

  • Heap

  • Stack

  • JVM

  • Class

Q 14. Which of the following statements are incorrect?

  • Public members of class can be accessed by any code in the program

  • Private members of class can be inherited by a subclass, and become protected members in subclass.

  • Private members of class can only be accessed by other members of the class.

  • Protected members of a class can be inherited by a subclass, and become private members of the subclass.

Q 15. Using which of the following, multiple inheritance in Java can be implemented?

  • Interfaces

  • Multithreading

  • Private methods

  • Protected methods



Intermediate Java Placement Questions

Q 16. What is the output of a Bitwise AND (&) operation if one of the inputs/operands is 0?

  • 0

  • 1

  • 0 or 1

  • 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?

  • 32

  • 64

  • 128

  • None of the above

Q 18. What does AWT stand for?

  • All Window Tools

  • All Writing Tools

  • Abstract Window Toolkit

  • Abstract Writing Toolkit

Q 19. Which one creates an instance of an array?

  • int[ ] ia = new int[15];

  • char[ ] ca = "Some String";

  • float fa = new float[20];

  • int ia[ ] [ ] = { 4, 5, 6 }, { 1,2,3 };

Q 20. switch(x) { default: System.out.println("Hello"); } Which two are acceptable types for x? (i) byte (ii) long (iii) char (iv) float

  • i & iii

  • ii & iv

  • i & iv

  • ii & iii

Q 21. What is the numerical range of char?

  • 0 to 32767

  • 0 to 65535

  • -256 to 255

  • -32768 to 32767

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

  • size()

  • length()

  • index()

  • capacity()

Q 23. How can we remove an object from ArrayList?

  • remove() method

  • using iterator

  • remove () method and using iterator

  • delete() method

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

  • finally

  • try

  • throw

  • catch

Q 25. Which component is responsible to optimize bytecode to machine code?

  • JVM

  • JDK

  • JIT

  • JRE

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

  • (int)Math.random()

  • (int)Math.random()+1

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

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

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 + ", "); } }

  • 9,8,7,6,5

  • Compilation fails

  • An exception is thrown at runtime

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

  • i & iv

  • ii & iii

  • iii & iv

  • ii & iv

Q 29. Which is true about a method-local inner class?

  • It must be marked final.

  • It can be marked abstract.

  • It can be marked public.

  • It can be marked static.

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

  • Static

  • Constant

  • Protected

  • Final

Advance Java Placement Questions


Q 31. which of these class is super class of every class in java?

  • String

  • Object

  • Abstract

  • Array list

Correct Answer & Explanation: b

Object class is super class of every class in Java.

Q 32. Which operator is used to invert all the digits in binary representation of a number ?

  • ~

  • <<<

  • >>>

  • ^

Q 33. What is the output of relational operators?

  • Integer

  • Boolean

  • Characters

  • Double

Q 34. Which of these have highest precedence?

  • ()

  • "++"

  • *

  • >>

Q 35. Which of the following is a superclass of all exception type classes?

  • Catchable

  • RuntimeExceptions

  • String

  • Throwable

Q 36. Which of these keywords are used for the block to handle the exceptions generated by try block?

  • Try

  • Catch

  • Throw

  • Check

Q 37. Which of these are types of multitasking?

  • Process based

  • Thread based

  • Process and thread based

  • None of the above

Q 38. What does not prevent JVM from terminating?

  • Process

  • Daemon thread

  • User thread

  • JVM thread

Q 39. What is the output of this program? class Abc { public static void main(String[]args) { String[] elements = {“for”,”tea”,”too”}; String first =(elements.length>0)? } }

  • Compilation error

  • An exception is thrown at runtime

  • The variable first is set to elements[0]

Q 40. All the variables of interface should be

  • Default and final

  • Default and static

  • Public, static and final

  • None of the above

Q 41. Which of these method is given parameter via command line arguments?

  • main()

  • Recursive()method

  • Any method

  • None of the above

Q 42. Which of these packages contains the exception Stack Overflow in Java?

  • java.lang

  • java.util

  • java.io

  • java.system

Q 43. What is the use if interpreter?

  • They convert bitecode to machine code.

  • They read high level code and execute them.

  • They are intermediated between JIT and JVM.

  • It is a synonym of JIT.

Q 44. Which of these handles the exception when no catch is used?

  • Default handler

  • Finally

  • Throw Handler

  • Java Runtime System

Q 45. What exception throw by parseInt() method?

  • ArithmeticExecption

  • ClassNotFoundExecption

  • NullPointerExecption

  • NumberFormatExecption

Q 46. What is the premise of equality for IdentityHashMap?

  • Reference Equality

  • Name equality

  • Hashcode equality

  • Length equality

Q 47. How to sort elements of Arraylist?

  • Collection.sort(listObj);

  • Collections.sort(listObj);

  • listObj.sort();

  • Sorter.sortAsc(listObj);

Q 48. Which of these method of Object class is used to obtain class of an object at run time?

  • get()

  • void getclass()

  • Class getclass()

  • None of the mentioned



 

These Java interview questions would give you an insight into what kind of questions could be asked.

 

#DS #algorithm

60 views0 comments

Recent Posts

See All