Interfaces And Abstract Classes — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Interfaces And Abstract Classes — 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
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an abstract class extend another class?
Correct Answer: Option B — Yes, abstract classes can extend both abstract and concrete classes
Detailed Academic Explanation:
In Java, abstract classes can extend both abstract and concrete classes. When an abstract class extends another class (whether abstract or concrete), it inherits the properties and methods of that class. An abstract class is allowed to inherit from a concrete class and can override or use the methods from the superclass. Option A is incorrect because abstract classes can extend other classes. Option C is incorrect since there is no requirement for the superclass to be marked as "static." Option D is incorrect as the subclass does not need to be marked "final" to extend a class.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
interface Base{ boolean m1 (); byte m2(short s); } which two code fragments will compile? 1. interface Base2 implements Base {} 2. abstract class Class2 extends Base { public boolean m1(){ return true; }} 3. abstract class Class2 implements Base {} 4. abstract class Class2 implements Base { public boolean m1(){ return (7 > 4); }} 5. abstract class Class2 implements Base { protected boolean m1(){ return (5 > 7) }}
Correct Answer: Option C — 3 and 4
Detailed Academic Explanation:
(3) is correct because an abstract class doesn't have to implement any or all of its interface's methods. (4) is correct because this method is correctly implemented ((7 > 4) is a boolean). (1) is incorrect because interfaces doesn't implement anything. (2) is incorrect because classes don't extend interfaces. (5) is incorrect because interface methods are implicitly public, so the methods being implemented must be public.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which two of the following are legal declarations for abstract classes and interfaces? 1. final abstract class Test {} 2. public static interface Test {} 3. final public class Test {} 4. protected abstract class Test {} 5. protected interface Test {} 6. abstract public class Test {}
Correct Answer: Option E — 3 and 6
Detailed Academic Explanation:
(3), (6). Both are legal class declarations. (1) is wrong because a class cannot be abstract and final "there would be no way to use such a class". (2) is wrong because interfaces and classes cannot be marked as static . (4) and (5) are wrong because classes and interfaces cannot be marked as protected .
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will happen after compiling this program code? abstract class MyClass{ //line 1 private int a, b; public void call(int a, int b){ this.a = a; this.b = b; System.out.print(a+b); } } public class Test{ public static void main(String args[]){ MyClass m = new MyClass(); //line 2 m.call(12,25); } }
Correct Answer: Option C — Compilation error due to line 2
Detailed Academic Explanation:
Abstract class is not concrete class which means object cannot be created for abstract class, its requires extending it and then create the object of extended class.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output for the below code? interface A{ public void printValue(); } public class Test{ public static void main (String[] args){ A a1 = new A(){ public void printValue(){ System.out.println("A"); } }; a1.printValue(); } }
Correct Answer: Option B — A
Detailed Academic Explanation:
The A a1 reference variable refers not to an instance of interface A, but to an instance of an anonymous (unnamed) class. So there is no compilation error.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output? public interface InfA{ protected String getName(); } public class Test implements InfA{ public String getName(){ return "test-name"; } public static void main (String[] args){ Test t = new Test(); System.out.println(t.getName()); } }
Correct Answer: Option B — Compilation fails due to an error on lines 2
Detailed Academic Explanation:
Illegal modifier for the interface method InfA.getName(); only public and abstracts are permitted.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output for the below code? public interface TestInf{ int i =10; } public class Test{ public static void main(String... args){ TestInf.i=12; System.out.println(TestInf.i); } }
Correct Answer: Option A — Compile with error
Detailed Academic Explanation:
All the variables declared in interface is implicitly static and final , therefore can't change the value.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output when the following program is compiled and executed? abstract class TestAbstract{ String my_name; String myName(){ my_name = "Examveda"; return my_name; } abstract void display(); } public class Test extends TestAbstract{ void display(){ String n = myName(); System.out.print("My name is "+ n); } public static void main(String args[]){ Test t = new Test(); t.display(); } }
Correct Answer: Option A — Program will compile and execute successfully and prints
Detailed Academic Explanation:
The options B, C and D are incorrect options as in Java we can declare an abstract class comprising of abstract and non-abstract methods that will not lead to any compilation error. Therefore, option A is the correct answer implying that the 't' instance of Test class invokes the display method, which is implemented in the Test class. The display method invokes myName() method declared int the TestAbstract class and prints the name.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if the following program is compiled and executed? interface MyInterface{ void display(); } interface MySubInterface extends MyInterface{ void display(); } public class Test implements MySubInterface{ public void display(){ System.out.print("Welcome to Examveda."); } public static void main(String args[]){ Test t = new Test(); t.display(); } }
Correct Answer: Option C — The code will compile and execute successfully showing the output Welcome to Examveda.
Detailed Academic Explanation:
The program will compile and execute successfully as you can declare methods with same name in an interface and the method of either interface can be used, implying the option a is incorrect. The option B and D are incorrect as the methods of an interface are implicitly public and abstract.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is an interface in Java?
Correct Answer: Option A — A contract specifying a set of methods that a class must implement
Detailed Academic Explanation:
A contract specifying a set of methods that a class must implement is the correct answer to “What is an interface in Java”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can a class implement multiple interfaces?
Correct Answer: Option D — Yes, a class can implement multiple interfaces
Detailed Academic Explanation:
Yes, a class can implement multiple interfaces is the correct answer to “In Java, can a class implement multiple interfaces”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to declare an interface in Java?
Correct Answer: Option C — interface
Detailed Academic Explanation:
interface is the correct answer to “Which keyword is used to declare an interface in Java”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of an abstract class in Java?
Correct Answer: Option B — To provide a base class with common methods and fields
Detailed Academic Explanation:
To provide a base class with common methods and fields is the correct answer to “What is the purpose of an abstract class in Java”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an abstract class be instantiated?
Correct Answer: Option C — No, an abstract class cannot be instantiated
Detailed Academic Explanation:
No, an abstract class cannot be instantiated is the correct answer to “In Java, can an abstract class be instantiated”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the "implements" keyword in Java?
Correct Answer: Option D — To indicate that a class is implementing an interface
Detailed Academic Explanation:
To indicate that a class is implementing an interface is the correct answer to “What is the purpose of the "implements" keyword in Java”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following can contain both abstract and non-abstract methods?
Correct Answer: Option A — Abstract class
Detailed Academic Explanation:
Abstract class is the correct answer to “Which of the following can contain both abstract and non-abstract methods”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an interface have fields (member variables)?
Correct Answer: Option D — Yes, an interface can have constant (final) fields
Detailed Academic Explanation:
Yes, an interface can have constant (final) fields is the correct answer to “In Java, can an interface have fields (member variables)”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of an abstract method in an abstract class or interface?
Correct Answer: Option C — To declare a method without providing an implementation
Detailed Academic Explanation:
To declare a method without providing an implementation is the correct answer to “What is the purpose of an abstract method in an abstract class or interface”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to define an abstract method in Java?
Correct Answer: Option B — abstract
Detailed Academic Explanation:
abstract is the correct answer to “Which keyword is used to define an abstract method in Java”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an interface have private methods with implementations?
Correct Answer: Option C — Yes, starting from Java 9, interfaces can have private methods
Detailed Academic Explanation:
Yes, starting from Java 9, interfaces can have private methods is the correct answer to “In Java, can an interface have private methods with implementations”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following code snippet? interface MyInterface { void myMethod(); } public class MyClass implements MyInterface { public void myMethod() { System.out.println("Implementation"); } public static void main(String[] args) { MyInterface obj = new MyClass(); obj.myMethod(); } }
Correct Answer: Option D — Implementation
Detailed Academic Explanation:
Implementation is the correct answer to “What is the result of the following code snippet? interface MyInterface { void myMethod(); } public class MyClass implements MyInterface { public void myMethod() { System.out.println("Implementation"); } public static void main(String[] args) { MyInterface obj = new MyClass(); obj.myMethod(); } }”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the "extends" keyword in Java?
Correct Answer: Option D — To create a subclass
Detailed Academic Explanation:
To create a subclass is the correct answer to “What is the purpose of the "extends" keyword in Java”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an interface extend another interface?
Correct Answer: Option C — Yes, an interface can extend multiple interfaces
Detailed Academic Explanation:
Yes, an interface can extend multiple interfaces is the correct answer to “In Java, can an interface extend another interface”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following code snippet? abstract class MyAbstract { abstract void myMethod(); } class MyClass extends MyAbstract { void myMethod() { System.out.println("Implementation"); } public static void main(String[] args) { MyAbstract obj = new MyClass(); obj.myMethod(); } }
Correct Answer: Option B — Implementation
Detailed Academic Explanation:
Implementation is the correct answer to “What is the result of the following code snippet? abstract class MyAbstract { abstract void myMethod(); } class MyClass extends MyAbstract { void myMethod() { System.out.println("Implementation"); } public static void main(String[] args) { MyAbstract obj = new MyClass(); obj.myMethod(); } }”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an abstract class have non-abstract methods?
Correct Answer: Option C — Yes, an abstract class can have both abstract and non-abstract methods
Detailed Academic Explanation:
Yes, an abstract class can have both abstract and non-abstract methods is the correct answer to “In Java, can an abstract class have non-abstract methods”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the "default" keyword in Java interfaces?
Correct Answer: Option D — To specify the default implementation of a method
Detailed Academic Explanation:
To specify the default implementation of a method is the correct answer to “What is the purpose of the "default" keyword in Java interfaces”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following code snippet? interface MyInterface { default void myMethod() { System.out.println("Default Implementation"); } } class MyClass implements MyInterface { public static void main(String[] args) { MyInterface obj = new MyClass(); obj.myMethod(); } }
Correct Answer: Option A — Default Implementation
Detailed Academic Explanation:
Default Implementation is the correct answer to “What is the result of the following code snippet? interface MyInterface { default void myMethod() { System.out.println("Default Implementation"); } } class MyClass implements MyInterface { public static void main(String[] args) { MyInterface obj = new MyClass(); obj.myMethod(); } }”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can a class implement an interface and extend an abstract class simultaneously?
Correct Answer: Option D — Yes, a class can implement an interface and extend an abstract class
Detailed Academic Explanation:
Yes, a class can implement an interface and extend an abstract class is the correct answer to “In Java, can a class implement an interface and extend an abstract class simultaneously”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the "final" keyword in Java?
Correct Answer: Option C — To indicate that a class, method, or variable cannot be further extended, overridden, or modified
Detailed Academic Explanation:
To indicate that a class, method, or variable cannot be further extended, overridden, or modified is the correct answer to “What is the purpose of the "final" keyword in Java”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an abstract class have constructors?
Correct Answer: Option B — Yes, an abstract class can have constructors
Detailed Academic Explanation:
Yes, an abstract class can have constructors is the correct answer to “In Java, can an abstract class have constructors”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following code snippet? abstract class MyAbstract { MyAbstract() { System.out.println("Constructor"); } } class MyClass extends MyAbstract { public static void main(String[] args) { MyClass obj = new MyClass(); } }
Correct Answer: Option C — Constructor
Detailed Academic Explanation:
Constructor is the correct answer to “What is the result of the following code snippet? abstract class MyAbstract { MyAbstract() { System.out.println("Constructor"); } } class MyClass extends MyAbstract { public static void main(String[] args) { MyClass obj = new MyClass(); } }”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an interface have static methods with implementations?
Correct Answer: Option D — Yes, starting from Java 8, interfaces can have static methods with implementations
Detailed Academic Explanation:
Yes, starting from Java 8, interfaces can have static methods with implementations is the correct answer to “In Java, can an interface have static methods with implementations”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following code snippet? interface MyInterface { static void myMethod() { System.out.println("Static Method"); } } class MyClass implements MyInterface { public static void main(String[] args) { MyInterface.myMethod(); } }
Correct Answer: Option A — Static Method
Detailed Academic Explanation:
Static Method is the correct answer to “What is the result of the following code snippet? interface MyInterface { static void myMethod() { System.out.println("Static Method"); } } class MyClass implements MyInterface { public static void main(String[] args) { MyInterface.myMethod(); } }”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an abstract class have private methods with implementations?
Correct Answer: Option D — Yes, starting from Java 9, abstract classes can have private methods with implementations
Detailed Academic Explanation:
Yes, starting from Java 9, abstract classes can have private methods with implementations is the correct answer to “In Java, can an abstract class have private methods with implementations”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following code snippet? abstract class MyAbstract { private void myMethod() { System.out.println("Private Method"); } } class MyClass extends MyAbstract { public static void main(String[] args) { MyClass obj = new MyClass(); obj.myMethod(); } }
Correct Answer: Option C — Compilation error
Detailed Academic Explanation:
Compilation error is the correct answer to “What is the result of the following code snippet? abstract class MyAbstract { private void myMethod() { System.out.println("Private Method"); } } class MyClass extends MyAbstract { public static void main(String[] args) { MyClass obj = new MyClass(); obj.myMethod(); } }”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an abstract class have static methods with implementations?
Correct Answer: Option B — Yes, an abstract class can have static methods with implementations
Detailed Academic Explanation:
Yes, an abstract class can have static methods with implementations is the correct answer to “In Java, can an abstract class have static methods with implementations”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the following code snippet? abstract class MyAbstract { static void myMethod() { System.out.println("Static Method"); } } class MyClass extends MyAbstract { public static void main(String[] args) { MyAbstract.myMethod(); } }
Correct Answer: Option C — Static Method
Detailed Academic Explanation:
Static Method is the correct answer to “What is the result of the following code snippet? abstract class MyAbstract { static void myMethod() { System.out.println("Static Method"); } } class MyClass extends MyAbstract { public static void main(String[] args) { MyAbstract.myMethod(); } }”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, can an abstract class have default methods with implementations?
Correct Answer: Option D — Yes, starting from Java 8, abstract classes can have default methods with implementations
Detailed Academic Explanation:
Yes, starting from Java 8, abstract classes can have default methods with implementations is the correct answer to “In Java, can an abstract class have default methods with implementations”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Given the following piece of code: public class School{ public abstract double numberOfStudent(); } which of the following statements is true?
Correct Answer: Option D — Class School must be defined abstract.
Detailed Academic Explanation:
Class School must be defined abstract. is the correct answer to “Given the following piece of code: public class School{ public abstract double numberOfStudent(); } which of the following statements is true”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following class definitions defines a legal abstract class?
Correct Answer: Option C — abstract class A { abstract void unfinished(); }
Detailed Academic Explanation:
abstract class A { abstract void unfinished(); } is the correct answer to “Which of the following class definitions defines a legal abstract class”. This question is standard in competitive examination syllabi for Interfaces And Abstract Classes.
💡Key Conceptual Anchor:Interfaces And Abstract Classes
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡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.