Spring Semester Quiz 6

Spring Semester Quiz 6

University

15 Qs

quiz-placeholder

Similar activities

Techii Quizzz

Techii Quizzz

University

10 Qs

Java Basics – Day 1 Quiz

Java Basics – Day 1 Quiz

University

10 Qs

CODEATHON'22

CODEATHON'22

University

20 Qs

Java Lesson 4

Java Lesson 4

5th Grade - University

10 Qs

IT203 Java Unit4 Post Test

IT203 Java Unit4 Post Test

University

10 Qs

HTML PHP C++

HTML PHP C++

University

10 Qs

Object Oriented Programming Quizz

Object Oriented Programming Quizz

University

10 Qs

IEEE Coding Competition

IEEE Coding Competition

University

13 Qs

Spring Semester Quiz 6

Spring Semester Quiz 6

Assessment

Quiz

Other

University

Easy

Created by

Ashong Nartey

Used 7+ times

FREE Resource

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.

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?