Scjp (310-055) Exam I

12 Questions | Attempts: 127
Share

SettingsSettingsSettings
Java Quizzes & Trivia

Self-study questions for Sun Certified Java Programmer (SCJP) (310-055). God speed!


Questions and Answers
  • 1. 
    Given the following, 1. interface Base {2. boolean m1 ();3. byte m2(short s);4. } Which code fragments will compile? (Choose all that apply.)
    • A. 

      Interface Base2 implements Base { }

    • B. 

      Abstract class Class2 extends Base { public boolean ml() { return true; } }

    • C. 

      Abstract class Class2 implements Base { }

    • D. 

      # abstract class Class2. implements Base { public boolean m1() { return (true); } }

    • E. 

      Class Class2 implements Base { boolean m1( ) { return false; } byte m2(short s) { return 42; } }

  • 2. 
    Which declare a compilable abstract class? (Choose all that apply.)
    • A. 

      Public abstract class Canine { public Bark speak(); }

    • B. 

      Public abstract class Canine { public Bark speak() { } }

    • C. 

      Public class Canine { public abstract Bark speak(); }

    • D. 

      Public class Canine abstract { public abstract Bark speak(); }

  • 3. 
    Which is true? (Choose all that apply. )
    • A. 

      "X extends Y" is correct if and only if X is a class and Y is an interface.

    • B. 

      "X extends Y" is correct if and only if X is an interface and Y is a class.

    • C. 

      "X extends Y" is correct if X and Y are either both classes or both interfaces.

    • D. 

      "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces.

  • 4. 
    Which are valid declarations? (Choose all that apply.)
    • A. 

      Int $x;

    • B. 

      Int 123;

    • C. 

      Int _123;

    • D. 

      Int #dim;

    • E. 

      Int central_sales_region_Summer_2005_gross_sales;

  • 5. 
    Which method names follow the JavaBeans standard? (Choose all that apply.)
    • A. 

      AddSize

    • B. 

      GetCust

    • C. 

      DeleteRep

    • D. 

      IsColorado

    • E. 

      PutDimensions

  • 6. 
    Given:1. class Voop {2. public static void main(String [] args) {3. doStuff(1);4. doStuff(1, 2);5. }6. // insert code here7. } Which, inserted independently at line 6, will compile? (Choose all that apply.)
    • A. 

      Static void doStuff(int... doArgs) { }

    • B. 

      Static void doStuff (int [] doArgs) { }

    • C. 

      Static void doStuff(int doArgs...) { }

    • D. 

      Static void doStuff(int... doArgs, int y) { }

    • E. 

      Static void doStuff(int x, int... doArgs) { }

  • 7. 
    Which statement(s) are true? (Choose all that apply.)
    • A. 

      Has-a relationships always rely on inheritance.

    • B. 

      Has-a relationships always rely on instance variables.

    • C. 

      Has-a relationships always require at least two class types

    • D. 

      Has-a relationships always rely on polymorphism.

    • E. 

      Has-a relationships are always tightly coupled.

  • 8. 
    Given: class Clidders { public final void flipper() { System.out.println("Clidder"); }}public class Clidlets extends Clidders { public void flipper() { System.out.println("Flip a Clidlet"); super.flipper(); } public static void main(String [] args) { new Clidlets().flipper(); }} What is the result?
    • A. 

      Flip a Clidlet

    • B. 

      Flip a Clidde

    • C. 

      Flip a Clidder Flip a Clidlet

    • D. 

      # Flip a Clidlet Flip a Clidder

    • E. 

      Compilation fails.

  • 9. 
    Given: public abstract interface Frobnicate { public void twiddle(String s) ; } Which is a correct class? (Choose all that apply.)
    • A. 

      Public abstract class Frob implements Frobnicate { public abstract void twiddle(String s){} }

    • B. 

      Public abstract class Frob implements Frobnicate { }

    • C. 

      Public class Frob extends 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) { } }

  • 10. 
    Given: class Top { public Top(String s) { System.out.print("B"); }}public class Bottom2 extends Top { public Bottom2(String s) { System.out.print("D"); } public static void main(String [] args) { new Bottom2("C"); System.out.println(" "); }}What is the result?
    • A. 

      BD

    • B. 

      DB

    • C. 

      BDC

    • D. 

      DBC

    • E. 

      Compilation fails.

  • 11. 
    Select the two statements that best indicate a situation with low coupling. (Choose two.)
    • A. 

      The attributes of the class are all private.

    • B. 

      The class refers to a small number of other objects.

    • C. 

      The object contains only a small number of variables.

    • D. 

      The reference variable is declared for an interface type, not a class. The interface provides a small number of methods.

    • E. 

      It is unlikely that changes made to one class will require any changes in another.

  • 12. 
    Given: class Clidder { private final void flipper() { System.out.println ("Clidder"); }}public class Clidlet extends Clidder { public final void flipper() { System.out.println("Clidlet"); } public static void main(String [] args) { new Clidlet().flipper(); }} What is the result?
    • A. 

      Clidlet

    • B. 

      Clidder

    • C. 

      Clidder Clidlet

    • D. 

      Clidlet Clidder

    • E. 

      Compilation fails.

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.