Flashcard on OOPs Concepts

Flashcard on OOPs Concepts

Assessment

Flashcard

Computers

University

Hard

Created by

Quizizz 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.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?