Home | Add to Favorites | Ebooks Directory | News  
SCJP Resources
Home
SCJP Article
SCJP 5.0
SCJP 1.2 Objectives
SCJP 1.4 Objectives
SCJP 5.0  Objectives
Free Simulator
Books
Free Questions
SCJP Faq
SCJP Mock exam
SCJP Dumps
SCJP Training
SCJP Sample questions

The following questions are sample questions for SCJP

If any queries regarding the questions or answers please mail us

 

61)

interface I{
final class C1   {     //1   
    static int i=9;;  //2
 }
}
class C2 implements I{
 public static void main(String a[]){
    System.out.println(I.C1.i);  ///3
}}


compile time error at line 1

compile time error at line 2

compile time error at line 3

prints 9

Runtime exception

Explanation:
interfaces classes are by default static,final. so,no compile time errors are genearated

Ans: 4


62)

class C{
public static void main(String[] args) {
  try
    {
        try
           {
               try
                 {
                   }
                 catch(RuntimeException e)
                 {
                  }
             }
           catch(Exception e)
           {
            }
              
      }
    catch(NullPointerException e)
    {
        }
     finally
    {
              System.out.println("finally");
 
      }
}}


Prints finally

compile time error

Runtime Exception

None of the above

Explanation:
No Explanation Available

Ans: 1

63)

class C {
  public static void main ( String ka [ ] ) {
          while ( false ) {
                  System.out.println ( "Value" ) ;
          }
  }
}


compile time error

prints Value infinitely

Runtime Exception

None of the above

Explanation:
No Explanation Available

Ans: 1

64)

class C {
public static void main(String[] args) {
  System.out.println(4+5+"String");
}}


prints 9string

prints 45string

compile time error

Runtime exception

None of the above

Explanation:
arguments to the method are evalutated from left to right so 4+5+"string" ==> 9+string==>9string

Ans: 1

65)

class H {
  public static void main (String[] args) {
    String s1 = "HHH";
    StringBuffer sb2 = new StringBuffer(s1);
    System.out.print(sb2.equals(s1) + "," + s1.equals(sb2));
}}


Prints: false,false

Prints: true,false

Prints: false,true

Prints: true,true

None of the above

Explanation:
s1 and sb2 are pointing to different object references

Ans: 1

66)

The relationship between a class and its superclass is


has-a

is -a

None of the above

Explanation:
No Explanation available

Ans: 2

67)

class A extends Thread {
  private int i;
  public void run() {i = 1;}
  public static void main(String[] args) {
    A a = new A();
    a.run();
    System.out.print(a.i);
}}
How many threads are created in this Program?


Ans: 1

Ans: 2

Ans: 3

0

None of the above

Explanation:
Main thread is a thread and calling run methods will not creat thread.

Ans: 1

68)

String objects once created can not be modified


true

false

Explanation:
No Explanation available

Ans: 1

69)

Which of the following modifiers can be applied to a class that is not a nested class?


public

protected

private

static

Explanation:
No Explanation Available

Ans: 1

                                                                                Go To Index