HomeCode HereJava methods and objects quiz Java methods and objects quiz Admin 1 min read Updated November 16, 2026 Nine questions on methods, parameters, classes, constructors and encapsulation. Java Java methods and objects quiz 9 questions, instant feedback Question 1 of 9 What does a method's return type void mean? A It returns null B It returns nothing C It returns an int D It cannot be called void declares that the method produces no value, so it cannot be used in an expression. Question 2 of 9 What is method overloading? A Two methods with the same name and different parameters B A method that calls itself C Replacing a parent method D A method with no body Overloading distinguishes methods by parameter list. Overriding replaces an inherited method with the same signature. Question 3 of 9 What does a constructor do? A Returns a value B Initialises a new object C Destroys an object D Copies a class A constructor runs when an object is created and sets up its initial state. It has no return type. Question 4 of 9 What happens if a class declares no constructor? A It cannot be instantiated B Java supplies a no-argument constructor C A compile error D The fields stay unset The compiler adds a default constructor that takes no arguments. Declaring any constructor removes it. Question 5 of 9 Why make a field private? A To save memory B To control access through methods C To make it final D To allow inheritance Private fields can only be changed by the class itself, so invariants can be enforced in one place. Question 6 of 9 What does the this keyword refer to? A The class B The current object C The parent class D A static field this is a reference to the object the method was called on, which disambiguates fields from parameters. Question 7 of 9 What does static mean on a method? A It belongs to the class, not an instance B It cannot be called C It is private D It runs once A static method is called on the class, such as Math.max, and has no access to instance fields. Question 8 of 9 Which pair of methods should usually be overridden together? A toString and main B equals and hashCode C get and set D start and stop Equal objects must have equal hash codes. Overriding one without the other breaks hash-based collections. Question 9 of 9 What is a getter for? A Changing a field B Reading a field's value through a method C Creating an object D Deleting an object A getter returns the value and can apply logic, such as returning a copy or a computed value. Check my answers Try again Your answers stay in this browser. Nothing is sent to a server. More quizzes Java getting started quiz Coming soon Java control flow quiz 9 questions Java object-oriented design quiz 9 questions All quizzes