Adaptive Practice

Object-Oriented

10 questions • Earn up to 98 XP • First attempt — go for 100%!

0
XP
0
Correct
x1
Combo
Question 1 of 10 ⏱ 0:30
Easy
Which of the following is NOT a fundamental concept of Object-Oriented Programming (OOP)?
Easy
In Java, which keyword is used to inherit a class?
Medium
What is the output of the following code snippet? class Animal { void sound() { System.out.println("Animal sound"); } } class Dog extends Animal { void sound() { System.out.println("Bark"); } } public class Test { public static void main(String[] args) { Animal a = new Dog(); a.sound(); } }
Easy
Which OOP principle is demonstrated when data members of a class are declared private and accessed via public methods?
Medium
Consider the following class hierarchy: class Vehicle { void start() { System.out.println("Vehicle starting"); } } class Car extends Vehicle { void start() { System.out.println("Car starting"); } } class ElectricCar extends Car { void start() { System.out.println("Electric Car starting silently"); } } What principle allows ElectricCar to have its own version of start() method?
Easy
Which of the following best describes 'Abstraction' in OOP?
Medium
In Java, which of the following is TRUE about an abstract class?
Easy
What is the output of the following code? interface Printable { void print(); } class Document implements Printable { public void print() { System.out.println("Printing Document"); } } public class Test { public static void main(String[] args) { Printable p = new Document(); p.print(); } }
Medium
Which of the following statements about constructors in Java is CORRECT?
Hard
Given the following code snippet: class A { int x = 10; void display() { System.out.println("A: " + x); } } class B extends A { int x = 20; void display() { System.out.println("B: " + x); } void show() { System.out.println("super.x = " + super.x); display(); } } public class Test { public static void main(String[] args) { B obj = new B(); obj.show(); } }

Loading...

Hey! 🔥 Your 7-day streak is at risk. Complete one quick quest today?

Streak broken? No worries. Recover with bonus XP by completing a quest now.