Search Header Logo

Spring Semester Quiz 6

Authored by Ashong Nartey

Other

University

Used 7+ times

Spring Semester Quiz 6
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What will be the output of the following code?

class A {

void display() {

System.out.println("Class A");

}

}

class B extends A {

void display() {

System.out.println("Class B");

}

}

public class Main {

public static void main(String[] args) {

A obj = new B();

obj.display();

}

}

Class A

Class B

Compilation Error

Runtime Error

2.

MULTIPLE SELECT QUESTION

20 sec • 3 pts

Which of the following statements about the Object class in Java is/are FALSE?

Every Java class extends Object class either directly or indirectly.

Only classes without a superclass extend Object class.

The Object class cannot be extended.

Object class is an abstract class.

3.

MULTIPLE SELECT QUESTION

20 sec • 3 pts

The following are not among the primary purposes of encapsulation in Java?

To restrict access to data and ensure data hiding.

To group related methods together.

To implement multiple inheritance.

To allow direct access to class fields.

4.

FILL IN THE BLANK QUESTION

20 sec • 1 pt

Which keyword is used to refer to the immediate parent class in Java?

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

What happens if an abstract class does not have any abstract methods?

Java will automatically provide an abstract method.

It will not compile.

The class can still be abstract.

It becomes a concrete class.

6.

FILL IN THE BLANK QUESTION

20 sec • 1 pt

What will be the output of this code?

class Animal {

void makeSound() {

System.out.println("Animal makes a sound");

}

}

class Dog extends Animal {

void makeSound() {

System.out.println("Dog barks");

}

}

public class Main {

public static void main(String[] args) {

Animal a = new Dog();

a.makeSound();

}

}

7.

MULTIPLE SELECT QUESTION

20 sec • 3 pts

Which of the following statements about abstract classes is/are FALSE?


Abstract classes cannot have constructors.

Abstract classes cannot have final methods.

An object of an abstract class cannot be instantiated.

Abstract classes cannot have static methods.

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?