QUIZ: Topic 2 - OOPS Concepts in Java Total Questions: 10 Instructions: Choose the most correct option (A, B, C or D) for each question. Check your answers using the Answer Key at the end. 1. In Java, a class can be best described as: A) A ready-to-run program that executes on its own B) A blueprint or template from which individual objects are created C) A reserved word used to declare variables D) A collection of only static methods 2. A method that performs an action but does not return any value must be declared with which return type? A) int B) double C) void D) static 3. Which import statement imports only the Scanner class from the java.util package? A) import java.util.*; B) import java.util.Scanner; C) import java.*; D) import Scanner; 4. Which of the following is TRUE about a constructor in Java? A) It must have the same name as the class in which it is defined B) It must declare a return type of void C) It can be declared static D) It can be called any number of times after the object is created 5. Which statement about static members in Java is correct? A) A static class can be created at the top level of a program B) Static members can be accessed without creating an object of the class C) Static members always have a return type of void D) Static methods cannot be called from inside the main method 6. Encapsulation in Java is best achieved by: A) Making all fields private and providing public getter and setter methods to access them B) Making all fields public so they can be changed directly C) Declaring every method as static D) Creating multiple classes in one file with no access restrictions 7. In inheritance, which keyword provides access to variables and methods in derived classes without violating the principle of encapsulation? A) private B) public C) protected D) final 8. Which statement about method overriding and polymorphism is TRUE? A) An overridden method must have a different signature from the parent method B) A method declared final in the parent class can be overridden in the child class C) The type of the object executing the method determines which version of the method is invoked D) Overriding and overloading are the same concept 9. Which statement about abstract classes and interfaces is TRUE? A) An abstract class can be instantiated if it contains at least one concrete method B) A class can implement multiple interfaces, and it must provide implementations for all the methods of the interface C) Interfaces can contain method signatures along with their implementations D) An abstract method can be declared static 10. Which statement about inner classes (nested classes) is TRUE? A) An inner class cannot access the private members of the outer class B) An inner class can access all the members of the outer class, including private data members and methods C) An inner class is always declared with the static keyword D) An inner class can contain only static methods ANSWER KEY 1. B) A class is defined as a blueprint or logical template from which individual objects are created, and it does not consume space by itself. 2. C) A void method does not return a value; methods that return values use types such as int or double. 3. B) The specific import java.util.Scanner imports only the Scanner class, while the wildcard import uses the asterisk (*). 4. A) Constructors must have the same name as the class, have no return type, and are called only once at the time of object creation. 5. B) Static classes and members are used to access members without creating objects; Java does not allow static classes at the top level. 6. A) Encapsulation keeps fields private inside the class and provides access to them through public methods, giving data hiding and modularity. 7. C) Protected members are visible in derived classes and can be inherited without violating encapsulation, while private members are not visible in derived classes. 8. C) In dynamic binding, the type of the object executing the method decides which version of the method runs; a final method cannot be overridden. 9. B) An interface contains only method signatures without implementation, and a class that implements it (possibly several interfaces) must define all its methods. 10. B) An inner class is declared inside another class or interface and can access all members of the outer class, including private data members and methods.