Search Header Logo

Quiz 3

Authored by Kanyanut HOMSAPAYA

English

University

Used 6+ times

Quiz 3
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

13 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

1. Which statements are true? Select the two correct answers.

(A) In Java, the extends clause is used to specify the inheritance relationship.

(B) The subclass of a non-abstract class can be declared abstract.

(C) All members of the superclass are inherited by the subclass.

(D) A final class can be abstract.

(E) A class in which all the members are declared private, cannot be declared public.

(A) and (B)

(B) and (C)

(A) and (E)

(C) and (D)

(D) and (E)

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

2. Which statements are true? Select the two correct answers.

(A) A class can only be extended by one class.

(B) Every Java object has a public method named equals.

(C) Every Java object has a public method named length.

(D) A class can extend any number of classes.

(E) A non-final class can be extended by any number of classes.

(B) and (C)

(A) and (B)

(B) and (E)

(C) and (D)

(D) and (E)

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Given the following classes and declarations, which statements are true?  Select the three correct answers.

(A) The Bar class is a subclass of Foo.

(B) The statement b.f(); is legal.

(C) The statement a.j = 5; is legal.

(D) The statement a.g(); is legal.

(E) The statement b.i = 3; is legal.

(A), (B) and (D)

(A), (C) and (E)

(C), (D) and (E)

(B), (C) and (D)

(A), (D) and (E)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given classes A, B, and C, where B extends A, and C extends B, and where all classes implement the instance method void doIt(). How can the doIt() method in A be called from an instance method in C? Select the one correct answer.

super.doIt();

super.super.doIt();

this.super.doIt();

A.this.doIt();

((A) this).doIt();

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

Which method declarations, when inserted at (7), will not result in a compile-time error?  Select the two correct answers.

(A) public int step1(int i) { return 1; }

(B) public String step2(String str2, String str1) { return str1; }

(C) private void step2() { } (D) private static void step2() { }

(E) private static String step2(String str) { return str; }

(F) public MySuperclass makeIt() { return new MySuperclass(); }

(G) public MyClass makeIt2() { return new MyClass(); }

(B) and (G)

(A) and (E)

(C) and (D)

(F) and (G)

(C) and (F)

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What would be the result of compiling and running the following program? Select the one correct answer.

The code will compile and print |Toyota|Volvo|12345|54321|, when run.

The code will compile and print |Volvo|Toyota|12345|54321|, when run.

The code will compile and print |Toyota|Toyota|12345|12345|, when run.

The code will compile and print |Toyota|Toyota|12345|12345|, when run.

The code will compile and print |Volvo|Toyota|54321|54321|, when run.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of these field declarations are legal within the body of an interface? Select the two correct answers.

(A) public static int answer = 42;

(B) int answer;

(C) final static int answer = 42;

(D) public int answer = 42;

(E) private final static int answer = 42;

(A) and (B)

(A) and (C)

(C) and (E)

(D) and (E)

(B) and (D)

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?