Rumman Ansari
Home
Blog
Courses
Paid Courses
Authentication
D365 F&O MCQ Questions - X++ Programming Language MCQ
Digital Productivity
GH-300: GitHub Copilot
ICSE Computer Applications Class 10 – Previous Year Question Papers & Solutions
Java Fundamentals: Building Strong Foundations
Mastering JavaScript: From Fundamentals to Advanced Concepts
MB-500: Microsoft Dynamics 365: Finance and Operations Apps Developer
X++ Programming Fundamentals - D365 F&O Technical
X++ Programming Language
Free Courses
AB-730: Microsoft Certified: AI Business Professional
AJAX
AngularJS
Arithmetic Aptitude
Artificial intelligence
Automata Theory
AZ-400: Designing and Implementing Microsoft DevOps Solutions
Azure DevOps for Beginners
Bangla to English
Biography
Biology
Bootstrap 4
C Programming Language
C Programming Language Video Bangla
C# Programming Language
C++ language
Competitive Exam
Computer Awareness
Computer Fundamentals
Computer Network
Computer Science and Engineering
Continuous Deployment
Continuous Integration
CSS
Current Affairs
Data Structure
Database Management System
Digital Logic
Education
Electrical Engineering
English
English Grammar
General Aptitude
Geography
History
HTML 5
Important Days and Dates
Interview Questions
ISC - COMPUTER SCIENCE - XI
Islam
Java Programming Language
JavaScript
Leadership behavior and Culture
Logical Fallacy
Machine Learning
Mastering HTML: From Fundamentals to Advanced Concepts
Mathematics
Mathematics for Programming
Mathematics in Bangla - Class 5
MB-310: Microsoft Certified: Dynamics 365 Finance Functional Consultant Associate
MB-330: Microsoft Certified: Dynamics 365 Supply Chain Management Functional Consultant Associate
MB-700: Microsoft Dynamics 365: Finance and Operations Apps Solution Architect
MB-920: Microsoft Dynamics 365 Fundamentals (ERP)
Microservices Architecture
Microsoft Azure
Microsoft Excel - Bangla
Mindwork games
Miscellaneous Topics
Misconceptions about Islam
MySQL
Neural Networks and Deep Learning
NPM - Package Manager
Pakistan Geography
Photoshop
PHP
Programming Language
Prompt Engineering
Puzzles
Python
R Programming Language
ReactJS
Science
Social Science
SQL
SQLite
Tamil Nadu State board (Class 10)
Technical MCQs
Technical Short Answers
TypeScript - JavaScript's Superset
UGC NET, SET
User Experience
Verbal and Reasoning
Vue JS
অতীত ও ঐতিহ্য: অষ্টম শ্রেণীর: পশ্চিমবঙ্গ মধ্যশিক্ষা পর্ষদ
অর্থনীতি
আরবী ভাষা কোর্স - Diploma in Arabic language
ইতিহাস
ইতিহাস ও পরিবেশ: দশম শ্রেণি: পশ্চিমবঙ্গ মধ্যশিক্ষা পর্ষদ
ইসলামিক বই
ইসলামে আকীকা
ইসলামে নারী
এসো আরবী শিখি
কুরআন
খাদ্য, পুষ্টি ও খাদ্যের উপাদান
জীবনবিজ্ঞান ও পরিবেশ (দশম)
তাহারাত কুইজ প্রতিযোগিতা
নবীদের কাহিনী - The story of the prophets
পরিবেশ ও বিজ্ঞান
প্যারেন্টিং - Parenting
প্রচলিত ভুল বিষয়ে প্রতিযোগিতা টেস্ট কুইজ
প্রশ্নোত্তরে ইসলামী জ্ঞান
বাংলা ইসলামিক কুইজ - Bangla Islamic Quiz
বাংলা সাহিত্য
ব্যক্তিগত উন্নয়ন (Personal Development)
ভূগোল
মডার্ন কম্পিউটার অ্যাপ্লিকেশন - একাদশ শ্রেণী
মডার্ন কম্পিউটার অ্যাপ্লিকেশন - দ্বাদশ শ্রেণী
লেখক এবং কবি
শয়তান পরিচিতি
সংক্ষিপ্ত জীবনী
সাধারণ জ্ঞান
সাহাবীদের জীবনী
সীরাত প্রতিযোগিতার প্রশ্ন ও উত্তরসমূহ
Guest
Profile
Logout
Green
Light
Dark
Java Interfaces And Abstract Classes MCQ
Answer all questions carefully. After submission, you will see a detailed result and answer review.
Question 1
What will be the output? <pre class="prettyprint"> 1. public interface InfA{ 2. protected String getName(); 3. } 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()); } } </pre>
A.
test-name
B.
Compilation fails due to an error on lines 1
C.
Compilation fails due to an error on lines 2
D.
Compilation succeed but Runtime Exception
Question 2
Which of the following class definitions defines a legal abstract class?
A.
class A { abstract void unfinished() { } }
B.
class A { abstract void unfinished(); }
C.
abstract class A { abstract void unfinished(); }
D.
public class abstract A { abstract void unfinished(); }
Question 3
Determine output of the following code. <pre class="prettyprint"> 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"); } } </pre>
A.
Nothing.
B.
b is an instance of A.
C.
b is an instance of C.
D.
b is an instance of A followed by b is an instance of C.
Question 4
What is the output for the below code ? <pre class="prettyprint"> interface A{ public void printValue(); } 1. public class Test{ 2. public static void main (String[] args){ 3. A a1 = new A(){ 4. public void printValue(){ 5. System.out.println("A"); 6. } 7. }; 8. a1.printValue(); 9. } 10. } </pre>
A.
Compilation fails due to an error on line 3
B.
A
C.
Compilation fails due to an error on line 8
D.
null
Question 5
What happens if the following program is compiled and executed? <pre class="prettyprint"> 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(); } } </pre>
A.
The code will lead to a compilation error as declaration of the display method has been provided in two interface.
B.
The code will lead to a compilation error due to public modifier while declaring the display method.
C.
The code will compile and execute successfully showing the output Welcome to Examveda.
D.
The code will lead to a compilation error as the display method is not declared as abstract.
Question 6
<pre class="prettyprint"> 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 } </pre> Which of the above line will give compilation error?
A.
1
B.
2
C.
3
D.
None of these
Question 7
What will be the output when the following program is compiled and executed? <pre class="prettyprint"> 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(); } } </pre>
A.
Program will compile and execute successfully and prints
B.
Compilation error as class can not be declared as abstract.
C.
Program compiles but leads to runtime exception.
D.
Compilation error occurs as the abstract class TestAbstract contains a non-abstract method.
Question 8
What will be the output? <pre class="prettyprint"> 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(); } } </pre>
A.
will print Class One method
B.
will print Class Two method
C.
compiles fine but print nothing
D.
Compilation Error
Question 9
Given the following piece of code: <pre class="prettyprint"> public class School{ public abstract double numberOfStudent(); } </pre> which of the following statements is true?
A.
The keywords public and abstract cannot be used together.
B.
The method numberOfStudent() in class School must have a body.
C.
You must add a return statement in method numberOfStudent().
D.
Class School must be defined abstract.
Question 10
Which two of the following are legal declarations for abstract classes and interfaces? <p>1. final abstract class Test {}<br />2. public static interface Test {}<br />3. final public class Test {}<br />4. protected abstract class Test {}<br />5. protected interface Test {}<br />6. abstract public class Test {}</p>
A.
1 and 2
B.
2 and 4
C.
3 and 5
D.
3 and 6
Submit Quiz