Search your topic in Java2share
Home > SCJP > QuestionBank
eXTReMe Tracker


2. Declarations and Access Control (SCJP)

Q: 1 Click the Task button.


Solution:

enum Element{
    EARTH,WIND,
    FIRE{public String info(){return "Hot";}
    };
    public String info(){return "element";}
}

Q: 2 Given:
10. package com.sun.scjp;
11. public class Geodetics {
12. public static final double DIAMETER = 12756.32; // kilometers
13. }

Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.)
A. import com.sun.scjp.Geodetics;
public class TerraCarta {
public double halfway()
{ return Geodetics.DIAMETER/2.0; }
B. import static com.sun.scjp.Geodetics;
public class TerraCarta{
public double halfway() { return DIAMETER/2.0; } }
C. import static com.sun.scjp.Geodetics.*;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }
D. package com.sun.scjp;
public class TerraCarta {
public double halfway() { return DIAMETER/2.0; } }

Answer: A, C

Q: 3 Click the Task button.

 Solution:

package com.sun.cert;
import java.util.*;
public class AddressBook{
    ArrayList entries;
}

Q: 4 Which two classes correctly implement both the java.lang.Runnable and the
java.lang.Clonable interfaces? (Choose

A. public class Session
implements Runnable, Clonable {
public void run();
public Object clone();
}
B. public class Session
extends Runnable, Clonable {
public void run() { /* do something */ }
public Object clone() { /* make a copy */ }
C. public class Session
implements Runnable, Clonable {
public void run() { /* do something */ }
public Object clone() { /* make a copy */ }
D. public abstract class Session
implements Runnable, Clonable {
public void run() { /* do something */ }
public Object clone() { /*make a copy */ }
E. public class Session
implements Runnable, implements Clonable {
public void run() { /* do something */ }
public Object clone() { /* make a copy */ }

Answer: C, D

3. Operators