Flashcard on OOPs Concepts

Flashcard on OOPs Concepts

Assessment

Flashcard

Computers

University

Practice Problem

Hard

Created by

Wayground Content

FREE Resource

Student preview

quiz-placeholder

28 questions

Show all answers

1.

FLASHCARD QUESTION

Front

What will be the output of the following code?
interface A {
void method();
}
abstract class B implements A {
public void method() {
System.out.println("Class B");
}
}
class C extends B {
}
public class Main {
public static void main(String[] args) {
C obj = new C();
obj.method();
}
}

Back

Class B

2.

FLASHCARD QUESTION

Front

What will be the output of the following code?
abstract class Animal { abstract void makeSound(); static void sleep() { System.out.println("Sleeping..."); } } class Dog extends Animal { void makeSound() { System.out.println("Bark"); } } public class Main { public static void main(String[] args) { Dog d = new Dog(); d.makeSound(); Animal.sleep(); } }

Back

Bark Sleeping...

3.

FLASHCARD QUESTION

Front

What will happen when the following code is executed?
interface A {
static void display() {
System.out.println("Interface A");
}
}
class B implements A {}
public class Main {
public static void main(String[] args) {
B obj = new B();
obj.display();
}
}
Options: A) Interface A, B) Compilation error, C) Runtime error, D) None of the above

Back

Compilation error

4.

FLASHCARD QUESTION

Front

What will be the output of the following code?
abstract class A { A() { System.out.println("Abstract class A constructor"); } } class B extends A { B() { System.out.println("Subclass B constructor"); } } public class Main { public static void main(String[] args) { B obj = new B(); } }

Back

Abstract class A constructor
Subclass B constructor

5.

FLASHCARD QUESTION

Front

Which of the following statements about abstract classes is FALSE?

Options: A) An abstract class can have final methods
, B) An abstract class can implement an interface
, C) An abstract class cannot have a constructor
, D) An abstract class can have static methods

Back

An abstract class cannot have a constructor

6.

FLASHCARD QUESTION

Front

What is the correct way to define multiple interface implementations?

Options: A) class A extends B, C {}
, B) class A implements B, C {}
, C) class A implements B extends C {}
, D) class A implements B & C {}

Back

class A implements B, C {}

7.

FLASHCARD QUESTION

Front

If a class implements multiple interfaces with methods having the same signature, what happens?

Back

The class must provide a single implementation for the method.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers