Which of the following is not a Java keyword? a) static b) Boolean c) void d) private → b) Boolean
Which company originally developed Java? a) Sun Microsystems b) Oracle c) IBM d) Microsoft → a) Sun Microsystems
Which method is the entry point of a Java program? a) start() b) run() c) main() d) init() → c) main()
What is the default value of an int variable in Java? a) 0 b) null c) undefined d) 1 → a) 0
Which of the following is used to compile Java code? a) javac b) java c) javadoc d) jar → a) javac
✅ OOPs Concepts
What is inheritance in Java? a) Using functions b) Creating new classes c) Acquiring properties of one class by another d) None → c) Acquiring properties of one class by another
Which keyword is used to inherit a class? a) implement b) extends c) inherit d) interface → b) extends
What is polymorphism? a) Overloading b) Overriding c) Both a and b d) None → c) Both a and b
Which of these is a superclass of all classes in Java? a) Object b) Class c) Parent d) Abstract → a) Object
What does encapsulation mean? a) Binding data and code b) Inheritance c) Overloading d) None → a) Binding data and code
✅ Data Types & Operators
Which data type is used to store a single character? a) String b) char c) Character d) int → b) char
What is the size of an int in Java? a) 4 bytes b) 2 bytes c) 8 bytes d) Depends on system → a) 4 bytes
Which operator is used for logical AND? a) & b) && c) | d) || → b) &&
Which type is not a primitive type? a) int b) float c) boolean d) String → d) String
What will be the result of 5/2 in Java? a) 2.5 b) 2 c) 3 d) Error → b) 2
✅ Control Statements
Which loop is guaranteed to execute at least once? a) for b) while c) do-while d) if → c) do-while
Which keyword is used to exit a loop? a) exit b) continue c) return d) break → d) break
What is used to skip current iteration in a loop? a) break b) return c) continue d) skip → c) continue
Which statement is used for decision-making? a) for b) if c) do d) loop → b) if
Which is the correct way to declare a switch statement? a) switch(){} b) switch case c) switch(variable){} d) if switch → c) switch(variable){ }
✅ Exception Handling
Which keyword is used to handle exceptions? a) try b) throw c) catch d) All of the above → d) All of the above
Which is a checked exception? a) ArithmeticException b) NullPointerException c) IOException d) ArrayIndexOutOfBoundsException → c) IOException
Which block is always executed? a) catch b) try c) finally d) throw → c) finally
How to throw an exception manually? a) throws b) throw c) catch d) try → b) throw
What does throws keyword indicate? a) Code execution b) Return type c) Exception declaration d) Loop → c) Exception declaration
✅ Classes & Objects
Which keyword is used to create an object? a) class b) new c) object d) this → b) new
What is a constructor? a) A variable b) A method c) A class d) A block to initialize objects → d) A block to initialize objects
Which of these is not a valid constructor type? a) Default b) Static c) Parameterized d) Copy → b) Static
What is this keyword in Java? a) Refers to parent object b) Refers to current object c) Refers to child class d) Refers to static context → b) Refers to current object
Which block is used for final cleanup of object? a) finalize() b) cleanup() c) destructor() d) close() → a) finalize()
✅ Inheritance, Interfaces & Abstract Classes
Which keyword is used to implement an interface? a) inherit b) extends c) implements d) override → c) implements
Can an interface contain constructor? a) Yes b) No → b) No
Can a class extend more than one class? a) Yes b) No → b) No
Can a class implement multiple interfaces? a) Yes b) No → a) Yes
Which is not a type of inheritance in Java? a) Single b) Hybrid c) Multilevel d) Multiple using class → b) Hybrid
✅ Advanced Java (String, Collections, Threads)
Which is immutable in Java? a) String b) StringBuilder c) Array d) Collection → a) String
Which method is used to find string length? a) size() b) getLength() c) length() d) count() → c) length()
Which interface provides dynamic array in Java? a) List b) Array c) Collection d) Set → a) List
Which class implements List interface? a) HashMap b) ArrayList c) HashSet d) Hashtable → b) ArrayList
Which collection does not allow duplicates? a) List b) Set c) ArrayList d) Map → b) Set
✅ Multithreading & Miscellaneous
Which method starts a thread execution? a) run() b) start() c) execute() d) init() → b) start()
Thread.sleep() pauses thread for: a) seconds b) milliseconds c) microseconds d) minutes → b) milliseconds
Which interface is used for threads? a) Runnable b) Threadable c) Executable d) Callable → a) Runnable
Which keyword is used for synchronization? a) sync b) synchronized c) lock d) mutex → b) synchronized
What is garbage collection in Java? a) Memory allocation b) Removing unused objects c) Cleaning files d) Managing exceptions → b) Removing unused objects
✅ Java Features & Keywords
Java is a ______ language. a) Platform dependent b) Platform independent c) Machine language d) Scripting → b) Platform independent
Which memory is used by JVM to store objects? a) Stack b) Heap c) Code d) Class → b) Heap
Which keyword makes a variable constant? a) constant b) final c) static d) const → b) final
Which of these is not a Java feature? a) Object-oriented b) Architecture-neutral c) Use of pointers d) Robust → c) Use of pointers
Which package contains Scanner class? a) java.util b) java.io c) java.lang d) java.awt → a) java.util