Search Header Logo

OCA Chuong 3

Authored by Chính Đồng

English

University

Used 5+ times

OCA Chuong 3
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 SELECT QUESTION

3 mins • 1 pt

Question 1: Given:

public abstract interface Frobnicate {

public void twiddle(String s);

}

A. public abstract class Frob implements Frobnicate {

public abstract void twiddle(String s){};

}

B. public abstract class Frob implements Frobnicate {

}

C. public class Frob extend Frobnicate {

public void twiddle(Integer i){};

}

D. public class Frob implements Frobnicate{

public void twiddle(Integer i){};

}

E. public class Frob implements Frobnicate {

public void twiddle(String i){}

public void twiddle(Integer s){}

}

2.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Question 2: Given:

class Top {

public Top(String s){

System.out.print("B");

}

}

public class Button2 extend Top {

public Button2(String s){

System.out.print("D");}

public static void main(String[] args){

new Button2("C");

System.out.println (" ")

}

}

A. BD

B. DB

C. BDC

D. DBC

E. Complilation fails

3.

MULTIPLE SELECT QUESTION

3 mins • 1 pt

Question 3: Given:

class Clidder {

private final void flipper() {

System.out.println("Clidder");}

}

public class Clidlet extend Clidder {

public final void flipper(){

System.out.println("Clidlet");

}

public static void main(Sring[] args) {

new Clidlet().flipper();

}

}

A. Clidlet

B. Clidder

C. Clidder

Clidlet

D. Clidlet

Clidder

E. Compilation fails

4.

FILL IN THE BLANK QUESTION

10 mins • 1 pt

Using the fragments bellow, complete the following code so it compiles. Note that you may not have to fill in all of the slots

Code:

class AgedP {

_____ ____ ____ ____ ____

public AgedP(int x) {

---- ---- ---- ---- ---- ----

}

}

public class Kinder extends AgedP {

____ ____ ____ ____ ____ ____

public Kinder (int x) {

____ ____ ____ ____ ____ ();

}

}

Fragments: Use the following fragments zero or more times:

AgedP super this ( { ) } ;

5.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

Question 5: Given:

class Bird {

{ System.out.print("b1");}

public Bird(){System.out.print("b2");}

}

class Raptor extends Bird {

static { System.out.print("r1");}

public Raptor(){System.out.print("r2");}

{System.out.print("r3");}

static {System.out.print("r4");}

}

class Haw extend Raptor {

public static void main (String [] args) {

System.out.print("pre");

new Hawk();

System.out.println("hawk");}

}

A. pre b1 b2 r3 r2 hawk

B. pre b2 b1 r2 r3 hawk

C. pre b2 b1 r2 r3 hawk r1 r4

D. r1 r4 pre b2 b1 r2 r3 hawk

E. Compilation fails

6.

MULTIPLE SELECT QUESTION

15 mins • 1 pt

Question 6: Given the following:

1. class X {void do1(){}}

2. class Y extends X {void do2() {}}

3. class Chrome {

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

5. X x1 = new X();

6. X x2 = new Y();

7. Y y1 = new Y();

8/ // insert code here

9. }}

Which of the following, inserted at line 8, will compile? (choose all that apply)

A. x2.do2();

B. (Y)x2.do2();

C. ((Y)x2).do2();

D. None of the above statements will compile

7.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Question 7: Given:

public class Locomotive {

Locomotive(){ main("hi");}

public static void main(String[] args){

System.out.print("2");

}

public static void main(String args){

System.out.print("3"+args);

}

}

A. 2 will be included in the output

B. 3 will be included in the output

C. hi will be included in the output

D. Compilation fails

E. An exception is thrown at runtime

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?