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
Inheritance in Java MCQ
Answer all questions carefully. After submission, you will see a detailed result and answer review.
Question 1
Which of the following is true? <p>1. A class can extend more than one class.<br />2. A class can extend only one class but many interfaces.<br />3. An interface can extend many interfaces.<br />4. An interface can implement many interfaces.<br />5. A class can extend one class and implement many interfaces.</p>
A.
1 and 2
B.
2 and 4
C.
3 and 5
D.
3 and 4
Question 2
Determine output: <pre class="prettyprint"> class A{ public void printName(){ System.out.println("Name-A"); } } class B extends A{ public void printName(){ System.out.println("Name-B"); } } class C extends A{ public void printName(){ System.out.println("Name-C"); } } 1. public class Test{ 2. public static void main (String[] args){ 3. B b = new B(); 4. C c = new C(); 5. b = c; 6. newPrint(b); 7. } 8. public static void newPrint(A a){ 9. a.printName(); 10. } 11. } </pre>
A.
Name B
B.
Name C
C.
Compilation fails due to an error on lines 5
D.
Compilation fails due to an error on lines 9
Question 3
Determine output: <pre class="prettyprint"> class A{ public void printValue(){ System.out.println("Value-A"); } } class B extends A{ public void printNameB(){ System.out.println("Name-B"); } } class C extends A{ public void printNameC(){ System.out.println("Name-C"); } } 1. public class Test{ 2. public static void main (String[] args){ 3. B b = new B(); 4. C c = new C(); 5. newPrint(b); 6. newPrint(c); 7. } 8. public static void newPrint(A a){ 9. a.printValue(); 10. } 11. } </pre>
A.
Value-A Name-B
B.
Value-A Value-A
C.
Value-A Name-C
D.
Name-B Name-C
Question 4
What will be printed after executing following program code? <pre class="prettyprint"> class Base{ int value = 0; Base(){ addValue(); } void addValue(){ value += 10; } int getValue(){ return value; } } class Derived extends Base{ Derived(){ addValue(); } void addValue(){ value += 20; } } public class Test{ public static void main(String[] args){ Base b = new Derived(); System.out.println(b.getValue()); } } </pre>
A.
30
B.
10
C.
40
D.
None of these
Question 5
A mechanism where one class acquires the properties of another class:
A.
Polymorphism
B.
Inheritance
C.
Encapsulation
D.
Abstraction
Question 6
A class member declared protected becomes member of subclass of which type?
A.
public member
B.
private member
C.
protected member
D.
static member
Question 7
What is the result of compiling and running this program? <pre class="prettyprint"> class Mammal{ void eat(Mammal m){ System.out.println("Mammal eats food"); } } class Cattle extends Mammal{ void eat(Cattle c){ System.out.println("Cattle eats hay"); } } class Horse extends Cattle{ void eat(Horse h){ System.out.println("Horse eats hay"); } } public class Test{ public static void main(String[] args){ Mammal h = new Horse(); Cattle c = new Horse(); c.eat(h); } } </pre>
A.
prints "Mammal eats food"
B.
prints "Cattle eats hay"
C.
prints "Horse eats hay"
D.
Class cast Exception at runtime.
Question 8
What is the output of this program? <pre class="prettyprint"> class A { public int i; public int j; A() { i = 1; j = 2; } } class B extends A { int a; B() { super(); } } class super_use { public static void main(String args[]) { B obj = new B(); System.out.println(obj.i + " " + obj.j) } } </pre>
A.
1 2
B.
2 1
C.
Runtime Error
D.
Compilation Error
Question 9
What is the output of this program? <pre class="prettyprint">class A { public int i; protected int j; } class B extends A { int j; void display() { super.j = 3; System.out.println(i + " " + j); } } class Output { public static void main(String args[]) { B obj = new B(); obj.i=1; obj.j=2; obj.display(); } } </pre>
A.
1 2
B.
2 1
C.
1 3
D.
3 1
Question 10
What will be the output? <pre class="prettyprint"> class A{ int i = 10; public void printValue(){ System.out.print("Value-A"); } } class B extends A{ int i = 12; public void printValue(){ System.out.print("Value-B"); } } public class Test{ public static void main(String args[]){ A a = new B(); a.printValue(); System.out.print(a.i); } } </pre>
A.
Value-B 11
B.
Value-B 10
C.
Value-A 10
D.
Value-A 11
Submit Quiz