Search Header Logo

Java Module 2 Quiz

Authored by Mr. V

Computers

University

Used 1+ times

Java Module 2 Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

hi hi

 

 

hi world

world world

Compilation fails.

An exception is thrown at runtime.

2.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

4

3

2

1

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

D

B

A

C,F

E

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Given:

11.  abstract class Vehicle { public int speed() { return 0; }

12.  class Car extends Vehicle { public int speed() { return 60; }

13.  class RaceCar extends Car { public int speed() { return 150; }

...

21.  RaceCar racer = new RaceCar();

22.  Car car = new RaceCar();

23.  Vehicle vehicle = new RaceCar();

24.  System.out.println(racer.speed() + ", " + car.speed()

25. + ", " + vehicle.speed());

What is the result?

0,0,0

150,60,0

150,150,150

60,0,150

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Given:

5.  class Building { }

6.  public class Barn extends Building {

7.  public static void main(String[] args) {

8.  Building build1 = new Building();

9.  Barn barn1 = new Barn();

10.  Barn barn2 = (Barn) build1;

11.  Object obj1 = (Object) build1;

12.  String str1 = (String) build1;

13.  Building build2 = (Building) barn1;

14. }

15. }

Which is true?

If line 10 is removed, the compilation succeeds.

 

If line 13 is removed, the compilation succeeds.

If line 11 is removed, the compilation succeeds.

More than one line must be removed for compilation to succeed.

If line 12 is removed, the compilation succeeds.

6.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Given:

21.  class Money {

22.  private String country = "Canada";

23.  public String getC() { return country; }

24. }

25.  class Yen extends Money {

26.  public String getC() { return super.country; }

27. }

28.  public class Euro extends Money {

29.  public String getC(int x) { return super.getC(); }

30.  public static void main(String[] args) {

31.  System.out.print(new Yen().getC() + " " + new Euro().getC());

32. }

33. }

What is the result?

null Canada

 

Compilation fails due to an error on line 26.

Canada null

Canada Canada

Compilation fails due to an error on line 29.

7.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What is the maximum number of levels possible in a Multilevel Inheritance in Java?

32

16

8

no limit

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