Skip to main content

Interfaces And Abstract Classes — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Interfaces And Abstract Classes — Part 2 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

Which of the following declares an abstract method in an abstract Java class?

Question 2 of 40
★ FPSC ★ PPSC

Which of the following statements regarding abstract classes are true?

Question 3 of 40
★ FPSC ★ PPSC

Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct? 1. A a = new A(); 2. A a = new B(); 3. B b = new A(); 4. B b = new B();

Question 4 of 40
★ FPSC ★ PPSC

Which of the following is a correct interface?

Question 5 of 40
★ FPSC ★ PPSC

Determine output of the following code. interface A { } class C { } class D extends C { } class B extends D implements A { } public class Test extends Thread{ public static void main(String[] args){ B b = new B(); if (b instanceof A) System.out.println("b is an instance of A"); if (b instanceof C) System.out.println("b is an instance of C"); } }

Question 6 of 40
★ FPSC ★ PPSC

Given the following piece of code: public interface Guard{ void doYourJob(); } abstract public class Dog implements Guard{ } which of the following statements is correct?

Question 7 of 40
★ FPSC ★ PPSC

In Java, declaring a class abstract is useful

Question 8 of 40
★ FPSC ★ PPSC

What will be the output? interface A{ public void method(); } class One{ public void method(){ System.out.println("Class One method"); } } class Two extends One implements A{ public void method(){ System.out.println("Class Two method"); } } public class Test extends Two{ public static void main(String[] args){ A a = new Two(); a.method(); } }

Question 9 of 40
★ FPSC ★ PPSC

interface Test{ int p = 10; //line 1 public int q = 20; //line 2 public static int r = 30; //line 3 public static final int s = 40; //line 4 } Which of the above line will give compilation error?

Question 10 of 40
★ FPSC ★ PPSC

Runnable is a _____ .

Question 11 of 40
★ FPSC ★ PPSC

Which object Java application uses to create a new process?

Question 12 of 40
★ FPSC ★ PPSC

Which of these method of Double wrapper can be used to check whether a given value is infinite or not?

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? interface calculate { int VAR = 0; void cal(int item); } class display implements calculate { int x; public void cal(int item) { if (item<2) x = VAR; else x = item * item; } } class interfaces { public static void main(String args[]) { display[] arr=new display[3]; for(int i=0;i<3;i++) arr[i]=new display(); arr[0].cal(0); arr[1].cal(1); arr[2].cal(2); System.out.print(arr[0].x+" " + arr[1].x + " " + arr[2].x); } }

Question 14 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class exception_handling { public static void main(String args[]) { try { int a[] = {1, 2,3 , 4, 5}; for (int i = 0; i < 5; ++i) System.out.print(a[i]); int x = 1/0; } catch(ArrayIndexOutOfBoundsException e) { System.out.print("A"); } catch(ArithmeticException e) { System.out.print("B"); } } }

Question 15 of 40
★ FPSC ★ PPSC

Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?

Question 16 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class exception_handling { public static void main(String args[]) { try { int a[] = {1, 2,3 , 4, 5}; for (int i = 0; i < 7; ++i) System.out.print(a[i]); } catch(ArrayIndexOutOfBoundsException e) { System.out.print("0"); } } }

Question 17 of 40
★ FPSC ★ PPSC

Which of these method of InputStream is used to read integer representation of next available byte input?

Question 18 of 40
★ FPSC ★ PPSC

The same import package/class be called twice in java?

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? import java.lang.System; class Output { public static void main(String args[]) { System.exit(5); } }

Question 20 of 40
★ FPSC ★ PPSC

What type of variable can be defined in an interface?

Question 21 of 40
★ FPSC ★ PPSC

How to use environment properties in the class?

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class Output { public static void main(String args[]) { String str = "true false"; boolean x = Boolean.parseBoolean(str); System.out.print(x); } }

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following Java code? import java.io.*; class files { public static void main(String args[]) { File obj = new File("/java/system"); System.out.print(obj.getName()); } }

Question 24 of 40
★ FPSC ★ PPSC

Which of these is a super class of wrappers Byte and short wrappers?

Question 25 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class exception_handling { public static void main(String args[]) { try { int a = 1; int b = 10 / a; try { if (a == 1) a = a / a - a; if (a == 2) { int c[] = {1}; c[8] = 9; } finally { System.out.print("A"); } } catch (NullPointerException e) { System.out.println("B"); } } }

Question 26 of 40
★ FPSC ★ PPSC

Which of these access specifiers can be used for an interface?

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? import java.lang.reflect.*; class Additional_packages { public static void main(String args[]) { try { Class c = Class.forName("java.awt.Dimension"); Constructor constructors[] = c.getConstructors(); for (int i = 0; i < constructors.length; i++) System.out.println(constructors[i]); } catch (Exception e) { System.out.print("Exception"); } } }

Question 28 of 40
★ FPSC ★ PPSC

Which of the following package stores all the standard java classes?

Question 29 of 40
★ FPSC ★ PPSC

What type of methods an interface contain by default?

Question 30 of 40
★ FPSC ★ PPSC

Which of these exceptions is thrown by compareTo() method defined in a double wrapper?

Question 31 of 40
★ FPSC ★ PPSC

Which of these methods is used to check for infinitely large and small values?

Question 32 of 40
★ FPSC ★ PPSC

What is true about the setProperties method?

Question 33 of 40
★ FPSC ★ PPSC

Java system properties can be set at runtime.

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following Java code? class Output { public static void main(String args[]) { byte a[] = { 65, 66, 67, 68, 69, 70 }; byte b[] = { 71, 72, 73, 74, 75, 76 }; System.arraycopy(a, 2, b, 1, a.length-2); System.out.print(new String(a) + " " + new String(b)); } }

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? (Note: file is made in c drive.) import java.io.*; class files { public static void main(String args[]) { File obj = new File("/java/system"); System.out.print(obj.getAbsolutePath()); } }

Question 36 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class Output { public static void main(String args[]) { String str = "true"; boolean x = Boolean.valueOf(str); System.out.print(x); } }

Question 37 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? (Note: file is made in c drive.) import java.io.*; class files { public static void main(String args[]) { File obj = new File("/java/system"); System.out.print(obj.canWrite()); System.out.print(" " + obj.canRead()); } }

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following Java program? class Output { public static void main(String args[]) { Integer i = new Integer(257); float x = i.floatValue(); System.out.print(x); } }

Question 39 of 40
★ FPSC ★ PPSC

Which of these class is used to read and write bytes in a file?

Question 40 of 40
★ FPSC ★ PPSC

Which of these method returns the remainder of dividend / divisor?

✓ 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 →