Quiz 5- OOAD (JAVA)

Quiz 5- OOAD (JAVA)

University

15 Qs

quiz-placeholder

Similar activities

UNIT-1 PYTHON BASICS

UNIT-1 PYTHON BASICS

University

10 Qs

1ºDAM/DAW - Entornos de Desarrollo - UD1-6 - Prof. C. Boni

1ºDAM/DAW - Entornos de Desarrollo - UD1-6 - Prof. C. Boni

University - Professional Development

20 Qs

Programing test

Programing test

1st Grade - University

10 Qs

Choose the level of Bloom’s Taxonomy

Choose the level of Bloom’s Taxonomy

University

10 Qs

basisdata1

basisdata1

University

20 Qs

OOP 1 Undiksha

OOP 1 Undiksha

12th Grade - University

13 Qs

SQL Quiz

SQL Quiz

University

18 Qs

Quiz 5- OOAD (JAVA)

Quiz 5- OOAD (JAVA)

Assessment

Quiz

Computers

University

Practice Problem

Medium

Created by

Dr. Pal

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following Java program?

class A {

A() {

System.out.print("A");

}

}

class B extends A {

B() {

System.out.print("B");

}

}

public class Test {

public static void main(String[] args) {

B obj = new B();

}

}

AB

BA

A

B

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

What is the output of the following Java program?

class A {

void method() {

System.out.println("A");

}

}

class B extends A {

void method() {

System.out.println("B");

}

}

public class Test {

public static void main(String[] args) {

A obj1 = new B();

B obj2 = (B) obj1;

obj2.method();

}

}

A

B

Compilation Error

Runtime Error

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following Java program?
class A {

static void staticMethod() {

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

}

void instanceMethod() {

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

}

}

class B extends A {

static void staticMethod() {

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

}

void instanceMethod() {

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

}

}

public class Test {

public static void main(String[] args) {

A aObj = new B();

B bObj = (B) aObj;

aObj.staticMethod();

bObj.instanceMethod();

}

}

A Static
B Instance

B Static
B Instance

Compilation Error

Runtime Error

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the output of the following Java program?

interface MyInterface {

void myMethod();

}

class MyClass implements MyInterface {

public void myMethod() {

System.out.println("MyClass");

}

}

public class Test {

public static void main(String[] args) {

MyInterface obj = new MyClass() {

public void myMethod() {

System.out.println("Anonymous Inner Class");

}

};

obj.myMethod();

}

}

MyClass

MyInterface

Anonymous Inner Class

Compilation Error

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following Java program?

class A {

final void show() {

System.out.println("A");

}

}

class B extends A {

void show() {

System.out.println("B");

}

}

public class Test {

public static void main(String[] args) {

A obj = new B();

obj.show();

}

}

A

B

Compilation Error

Runtime Error

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following Java program?

public class Test {

public static void main(String[] args) {

String s1 = "Hello";

String s2 = new String("Hello");

System.out.println(s1 == s2);

System.out.println(s1.equals(s2));

}

}

true

false

false

true

true

false

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following Java program?

public class Test {

public static void main(String[] args) {

String s1 = "Hello";

String s2 = "World";

String result = s1 + s2;

System.out.println(result == "HelloWorld"); // false

}

}

true

false

Compilation error

Runtime error

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