Methods in Java MCQs: 12 Solved Questions on Defining and Invoking Behaviors
Solve 12 Java method questions covering declarations, constructor chains, overloads, overrides, runtime binding, and recursive call traces.
KnowledgeGate Team
Exam prep & CS education

Java method MCQs become difficult when a short declaration hides several decisions: whether the code compiles, which overload is selected, which override runs, and what a recursive call prints. Read each declaration from its modifiers inward, then substitute actual argument values and follow control flow before choosing an option. Use Methods in Java: Syntax, Parameters, Return Values and Examples for declaration syntax, parameters, return values, and complete runnable programs; the questions here narrow the job to option selection and exact trace checking. The Coding & DSA category places this topic in the wider programming path.
1. Java method basics: Questions 1-2
Question 1
DSSSB 2021
Which of the following is/are correct about Java programming?
I. All functions in Java must be members of some class
II. Member functions are called methods in Java
A. Only I
B. Only II
C. Both I and II
D. Neither I nor II
Answer: C. Both I and II
Java executable behaviour is declared inside a class, interface, enum, or record. These member functions are methods. In class Counter { int next() { return 1; } }, next() belongs to Counter. Both statements express the exam-level rule, so C follows.
Question 2
UPLT 2026
The action in Java class are called:
A. methods
B. objects
C. functions
D. procedures
Answer: A. methods
A class groups fields, which hold state, and methods, which define behaviour. In class Lamp { void switchOn() {} }, switchOn() is the action; a runtime Lamp is an object. Therefore A is correct.
2. Java method declarations and access: Questions 3-4
Question 3
UGC NET 2015
In Java, when we implement an interface method, it must be declared as :
A. Private
B. Protected
C. Public
D. Friend
Answer: C. Public
An interface's abstract method is public by contract, so an implementing class cannot reduce its visibility:
interface Payable { void pay(); }
class Invoice implements Payable { public void pay() {} }Omitting public from Invoice.pay() would give it package-private access and cause compilation to fail. Java also has no friend access specifier.
Question 4
DSSSB 2021
Which of the following statement(s) is/are correct regarding java programming?
I. Place a semicolon immediately after a method header
II. Define a method outside the braces of a class definition
A. Only I
B. Only II
C. Both I and II
D. Neither I nor II
Answer: D. Neither I nor II
Compare the concrete declaration int twice(int x) { return 2 * x; } with the abstract declaration abstract int twice(int x);. A concrete method header is followed by a body, not an immediate semicolon. A Java method also remains inside its enclosing type's braces. Because the unqualified statements present both as general rules, neither is correct.
3. Invoking constructors and creating objects: Questions 5-6
Question 5
TPSC 2025
In Java, which of the following is the correct way to create an object of a class Person ?
A. Person obj = new Person();
B. new Person obj = new Person ();
C. Person obj = new();
D. Person new obj = Person ();
Answer: A. Person obj = new Person();
Option A has three exact pieces. Person is the reference type, obj is the variable, and new Person() invokes the no-argument constructor. That expression returns the reference assigned to obj. The other forms put new in an illegal position or omit the constructor's class name.
Question 6
Beltron Programmer 2025
What will be the output of the following code?
public class Test {
Test() {
System.out.print("A ");
}
Test(int x) {
this();
System.out.print("B ");
}
public static void main(String[] args) {
new Test(5);
}
}A. A
B. A B
C. B
D. Compilation error
Answer: B. A B
Trace the constructors in execution order. new Test(5) enters Test(int x). Its first statement, this(), invokes Test(), which prints A . Control returns to the integer constructor, which prints B . The visible output is A B, so B is correct.
4. Method overloading, overriding and call semantics: Questions 7-10
Question 7
RPSC 2024
What do you mean by Method Overloading in Java?
A. Having two methods with the same name in different packages.
B. Having two methods with the same name and same parameters.
C. Having two methods with the same name but different parameters.
D. Having two methods with the same name in different classes.
Answer: C. Having two methods with the same name but different parameters.
print(int x) and print(String x) share a name but differ in parameters. The compiler selects one from the argument at compile time. Return type alone cannot overload.
Question 8
UGC NET 2014; also tagged LTI Mindtree 2025
Which of the following differentiates between overloaded functions and overridden functions ?
A. Overloading is a dynamic or runtime binding and overridden is a static or compile time binding.
B. Overloading is a static or compile time binding and overriding is dynamic or runtime binding.
C. Redefining a function in a friend class is called overloading, while redefining a function in a derived class is called as overridden function.
D. Redefining a function in a derived class is called function overloading, while redefining a function in a friend class is called function overriding.
Answer: B. Overloading is a static or compile time binding and overriding is dynamic or runtime binding.
show(int) or show(String) is chosen at compile time. With Vehicle v = new Car(); v.move();, runtime class Car selects the override. Overloading is static; overriding is dynamic. Java calls them methods.
For the full design relationship among inheritance, polymorphism, abstraction, and encapsulation, use OOPs Concepts in Java. Questions 8 and 10 isolate the narrower method-overload and runtime-dispatch decisions.
Question 9
Capgemini 2024
Predict the output of the following Java program.
class IntWrap {
int x;
}
public class Main {
public static void main(String[] args) {
IntWrap i = new IntWrap();
i.x = 10;
IntWrap j = new IntWrap();
j.x = 20;
swap(i, j);
System.out.println("i.x = " + i.x + ", j.x = " + j.x);
}
public static void swap(IntWrap i, IntWrap j) {
int temp = i.x;
i.x = j.x;
j.x = temp;
}
}A. i.x = 20, j.x = 10
B. i.x = 10, j.x = 20
C. i.x = 10, j.x = 10
D. i.x = 20, j.x = 20
Answer: A. i.x = 20, j.x = 10
Java copies the two references into the method parameters, but both copies still point to the original objects. Assigning to i.x and j.x mutates those objects, so the caller observes the swapped field values. The output is i.x = 20, j.x = 10, so A is correct.
Question 10
RPSC 2024
What will be the output of the following code?
class Vehicle {
public void move() {
System.out.println("Vehicle is moving");
}
}
class Car extends Vehicle {
public void move() {
System.out.println("Car is moving");
}
}
public class Main {
public static void main(String[] args) {
Vehicle v = new Car();
v.move();
}
}A. Runtime error
B. Vehicle is moving / Vehicle is moving
C. Compilation error
D. Car is moving
Answer: D. Car is moving
v has declared type Vehicle but refers to a Car, so dynamic dispatch calls Car.move() once. The program prints Car is moving, so D is correct.
5. Recursive Java method traces: Questions 11-12

Question 11
UGC NET 2020
Consider the following recursive Java function f that takes two long arguments and returns a float value:
public static float f (long m, long n) {
float result = (float)m / (float)n;
if (m < 0 || n<0) return 0.0f;
else result -=f(m*2, n*3);
return result;
}Which of the following real values best approximates the value of f(1,3)?
A. 0.2
B. 0.4
C. 0.6
D. 0.8
Answer: A. 0.2
Expand the first terms as 1/3 - 2/9 + 4/27 - 8/81 + .... This is a geometric series with first term 1/3 and ratio -2/3. Its limit is (1/3) / (1 - (-2/3)) = (1/3) / (5/3) = 1/5 = 0.2.
Java's finite execution adds one detail. Repeated long multiplication makes n overflow negative at the 40th frame, where m = 549755813888 and n = -6289078614652622815, so the guard returns zero there. Float evaluation gives about 0.20000003, still closest to A.
Question 12
ISRO 2007
Study the following program:
// precondition: x>=0
public void demo(int x)
{
System.out.print(x % 10);
if (x % 10 != 0) {
demo(x / 10);
}
System.out.print(x % 10);
}Which of the following is printed as a result of the call demo(1234)?
A. 1441
B. 3443
C. 12344321
D. 4321001234
Answer: D. 4321001234
On descent, calls with 1234, 123, 12, 1, and 0 print 4, 3, 2, 1, and 0. The x = 0 frame skips recursion but makes the final print, adding a second 0. Unwinding prints 1, 2, 3, and 4. Together they give 4321001234, not C.

6. Methods in Java answer-pattern checklist
Clue in the question | Rule to apply |
|---|---|
| overloading |
| overriding |
| runtime dispatch |
| another constructor in the same class |
| constructor invocation |
| subclass cannot override it |
For recursion, record what happens before the recursive call and what happens after it. With actual values from Question 12, the descent is 4,3,2,1,0, while the unwind is 0,1,2,3,4. This simple split prevents you from reversing only half the trace or missing the second zero.
7. Methods in Java: the short version and next practice step
Keep this recall chain ready: method means class behaviour; an interface implementation is public; overload means parameters differ; override means runtime instance dispatch; this() forms a constructor chain; recursion means tracing descent and unwind separately.
Now repeat all 12 questions without looking at the options. Explain each answer with one exact artefact, such as new Person(), A B, Car is moving, 0.2, or 4321001234. For the complete sequence, use the Java course with concepts, MCQs and coding questions, then continue with String Handling in Java as a focused practice topic.
Keep learning
Classes and Objects in C\u002b\u002b: Data Members, Methods and a Worked State Trace
Build a precise model of C++ classes and objects, then follow two WaterTank instances through valid, rejected, and independent state changes.
Reflection in Java Tutorial: Inspect Classes and Invoke Methods at Runtime
Learn Java Reflection from its Class<?> entry point to runtime construction, field access and method invocation. Trace one complete program and diagnose its common failures.
Methods in Java: Syntax, Parameters, Return Values and Examples
Build and trace a complete Java score program, then learn how arguments, return types, void methods, instance calls and overloads work.
StringBuilder and StringBuffer in Java: Differences, Methods and Runnable Examples
Learn how Java's mutable text classes change character sequences, where their indexes matter, and when method-level synchronisation changes the right choice.





