JAVA DUMPS 15 (SCJP)

QUESTION NO: 78

Given:

11. public class Test {

12. public void foo() {

13. assert false;

14. assert false;

15. }

16. public void bar(){

17. while(true){

18. assert false;

19. }

20. assert false;

21. }

22. }

What causes compilation to fail?

A. Line 13

B. Line 14

C. Line 18

D. Line 20

Answer: D


 

QUESTION NO: 79

Which statement is true?

A. Programs will not run out of memory.

B. Objects that will never again be used are eligible for garbage collection.

C. Objects that are referred to by other objects will never be garbage collected.

D. Objects that can be reached from a live thread will never be garbage collected.

E. Objects are garbage collected immediately after the system recognizes they are

eligible.

Answer: D


 

QUESTION NO: 80I

n which two cases does the compiler supply a default constructor for class A? (Choose

two)

A. class A {

}

B. class A {

public A() {}

}

C. class A {

public A(int x) {}

}

D. class Z {}

class A extends Z {

void A() {}

}

Answer: A, D


 

QUESTION NO: 81

Given:

1. public class ReturnIt {

2. return Type methodA(byte x, double y) {

3. return (short)x / y * 2;

4. }

5. }

What is the narrowest valid returnType for methodA in line2?

A. int

B. byte

C. long

D. short

E. float

F. double

Answer: F


 

QUESTION NO: 82

Given:

1. public class Outer{

2. public void someOuterMethod() {

3. // Line 3

4. }

5. public class Inner{}

6. public static void main( String[]argv ) {

7. Outer o = new Outer();

8. // Line 8

9. }

10. }

Which instantiates an instance of Inner?

A. new Inner(); // At line 3

B. new Inner(); // At line 8

C. new o.Inner(); // At line 8

D. new Outer.Inner(); // At line 8

Answer: A


 

QUESTION NO: 83

What allows the programmer to destroy an object x?

A. x.delete()

B. x.finalize()

C. Runtime.getRuntime().gc()

D. Explicitly setting the object's reference to null.

E. Ensuring there are no references to the object.

F. Only the garbage collection system can destroy an object.

Answer: F


 

QUESTION NO: 84

Given:

11. int x = 1, y =6;

12. while (y--) {

13. x++;

14. }

15. System.out.println("x =" + x + "y =" +y);

What is the result?

A. x = 6 y = 0

B. x = 7 y = 0

C. x = 6 y = -1

D. x = 7 y = -1

E. Compilation fails.

Answer: D

2 comments:

Anonymous said...

The correct answer for 84 is E.
E. Compilation fails.

Expression of a while statement must return a boolean value.

Anonymous said...

The Correct answer for Question Number 84 is "E".Compilation fails.

Post a Comment