Skip to main content

Constructors And Methods — Part 1 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Constructors And Methods — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

What is the return type of a constructor in Java?

Question 2 of 40
★ FPSC ★ PPSC

What is the expected output? public class Profile { private Profile(int w) { // line 1 System.out.print(w); } public static Profile() { // line 5 System.out.print (10); } public static void main(String args[]) { Profile obj = new Profile(50); } }

Question 3 of 40
★ FPSC ★ PPSC

The following code contains one compilation error, find it? public class Test { Test() { } // line 1 static void Test() { this(); } // line 2 public static void main(String[] args) { // line 3 Test(); // line 4 } }

Question 4 of 40
★ FPSC ★ PPSC

Which of the following options is the best for generating random integer 0 or 1?

Question 5 of 40
★ FPSC ★ PPSC

What is Math.floor(3.6)?

Question 6 of 40
★ FPSC ★ PPSC

What is the expected output? public class Profile { private Profile(int w) { // line 1 System.out.print(w); } public final Profile() { // line 5 System.out.print(10); } public static void main(String args[]) { Profile obj = new Profile(50); } }

Question 7 of 40
★ FPSC ★ PPSC

What is the expected output? class Animal { Animal() { System.out.println("Animal"); } } class Wild extends Animal{ Wild() { System.out.println("Wild"); super(); } } public class Test { public static void main(String args[]) { Wild wild = new Wild(); } }

Question 8 of 40
★ FPSC ★ PPSC

Determine output of the following program. public class Test{ public static void main(String args[]){ System.out.println( Math.floor( Math.random( ) ) ) ; } }

Question 9 of 40
★ FPSC ★ PPSC

What is the output of the above program? class Num { Num(double x ){ System.out.println( x ) ; } } public class Test extends Num { public static void main(String[] args){ Num num = new Num( 2 ) ; } }

Question 10 of 40
★ FPSC ★ PPSC

Determine Output: class A{ public static void method(int i){ System.out.print("Method 1"); } public static int method(String str){ System.out.print("Method 2"); return 0; } } public class Test{ public static void main(String args[]){ A.method(5); } }

Question 11 of 40
★ FPSC ★ PPSC

What is the output of the program? class Test{ public int display(int x, int y){ return ("The sum of x and y is " + x + y); } public static void main(String args[]){ Test test = new Test(); System.out.println(test.display(4,5)); } }

Question 12 of 40
★ FPSC ★ PPSC

The implicit return type of a constructor is

Question 13 of 40
★ FPSC ★ PPSC

What is the prototype of the default constructor? public class Test { }

Question 14 of 40
★ FPSC ★ PPSC

What is the output of the program? class MyClass{ MyClass(){ System.out.print("one"); } public void myMethod(){ this(); System.out.print("two"); } } public class TestClass{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.myMethod(); } }

Question 15 of 40
★ FPSC ★ PPSC

Determine output: public class Test{ public static void main(String args[]){ MyClass obj = new MyClass(); obj.val = 1; obj.call(obj); System.out.println(obj.val); } } class MyClass{ public int val; public void call(MyClass ref){ ref.val++; } }

Question 16 of 40
★ FPSC ★ PPSC

public class MyClass{ } For the above class(MyClass) what is the correct way of declaring constructor?

Question 17 of 40
★ FPSC ★ PPSC

What is the output for the below code? public class A{ int add(int i, int j){ return i+j; } } public class B extends A{ public static void main(String argv[]){ short s = 9; System.out.println(add(s,6)); } }

Question 18 of 40
★ FPSC ★ PPSC

What is the output for the below code? public class Test{ public static void printValue(int i, int j, int k){ System.out.println("int"); } public static void printValue(byte...b){ System.out.println("long"); } public static void main(String... args){ byte b = 9; printValue(b,b,b); } }

Question 19 of 40
★ FPSC ★ PPSC

What is the output for the below code? class A{ public A(){ System.out.println("A"); } public A(int i){ this(); System.out.println(i); } } class B extends A{ public B(){ System.out.println("B"); } public B(int i){ this(); System.out.println(i+3); } } public class Test{ public static void main (String[] args){ new B(5); } }

Question 20 of 40
★ FPSC ★ PPSC

What will be the result of compiling and running the given code? class A{ int b=10; private A(){ this.b=7; } int f(){ return b; } } class B extends A{ int b; } public class Test{ public static void main(String[] args){ A a = new B(); System.out.println(a.f()); } }

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class recursion { int func (int n) { int result; result = func (n - 1); return result; } } class Output { public static void main(String args[]) { recursion obj = new recursion() ; System.out.print(obj.func(12)); } }

Question 22 of 40
★ FPSC ★ PPSC

What is a constructor in Java?

Question 23 of 40
★ FPSC ★ PPSC

Which keyword is used to define a method in Java?

Question 24 of 40
★ FPSC ★ PPSC

In Java, which method is automatically called when an object is created?

Question 25 of 40
★ FPSC ★ PPSC

What is method overloading in Java?

Question 26 of 40
★ FPSC ★ PPSC

What does the "void" keyword indicate in a method declaration?

Question 27 of 40
★ FPSC ★ PPSC

Which access modifier is used for a method that can be accessed from any class in the same package?

Question 28 of 40
★ FPSC ★ PPSC

What is the purpose of the "this" keyword in Java constructors and methods?

Question 29 of 40
★ FPSC ★ PPSC

Which keyword is used to prevent method overriding in Java?

Question 30 of 40
★ FPSC ★ PPSC

What is the correct syntax to call a method named "myMethod" from an object "myObject"?

Question 31 of 40
★ FPSC ★ PPSC

Which method is called when an object is garbage collected in Java?

Question 32 of 40
★ FPSC ★ PPSC

In Java, can a constructor have a return type?

Question 33 of 40
★ FPSC ★ PPSC

What is method overriding in Java?

Question 34 of 40
★ FPSC ★ PPSC

In Java, what is the purpose of the "super" keyword in a constructor?

Question 35 of 40
★ FPSC ★ PPSC

What is a "static" method in Java?

Question 36 of 40
★ FPSC ★ PPSC

What is a parameterized constructor in Java?

Question 37 of 40
★ FPSC ★ PPSC

Which keyword is used to call the constructor of the superclass in a subclass constructor?

Question 38 of 40
★ FPSC ★ PPSC

What is the purpose of method parameters in Java?

Question 39 of 40
★ FPSC ★ PPSC

In Java, which keyword is used to define an abstract method?

Question 40 of 40
★ FPSC ★ PPSC

What is method chaining in Java?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →