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.
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.
These top Java Placement questions have been segmented into three sections:
Basic Java Placement Questions
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.
Free Practice Tests
Most Important Interview Questions
Last Minute Class Notes
תגובות