Search This Blog

Thursday, February 10, 2011

SCJP 6 Question 28:

Which of these must be true if you execute the following command?
java –classpath xyz hello.my.App
Choose at least one answer.
a. The definition of the App class must be preceded by the statement 'package hello.my;'
b. The definition of the App class must be preceded by the statement 'package xyz.hello.my;'
c. The definition of the App class must be preceded by the statement 'package my;'
d. App.class must be found in xyz\hello\my directory
e. App.class must be found in xyz\hello directory
f. App.class must be found in xyz directory
SCJP 6 Question 28:SocialTwist Tell-a-Friend

Wednesday, February 9, 2011

SCJP 6 Question 27

What is the result of compiling and running the given code?

public class Regex1 {
  public static void main(String[] args){
    String str = "aaaaaaaaabb";
    String[] split = str.split("a{3}");
    System.out.println(split.length);    
  }
}


Choose one answer
a. Compiler error
b. Exception at runtime
c. Prints 0
d. Prints 1
e. Prints 2
f. Prints 3
g. Prints 4


SCJP 6 Question 27SocialTwist Tell-a-Friend

SCJP 6 Question 26:

What will happen when you attempt to compile and run the following code?

public class WrapTest {
  public static void main(String[] args) {
    String str = "19";
    str.concat(".5");
    Double d = new Double(str);
    Long l = new Long(str);
    System.out.println(d.intValue()+d.doubleValue()+l.doubleValue());
  }
}

Choose one answer.
a. It will print  57.5
b. It will print  57.0
c. It will print  58.0
d. Compilation error
e. Runtime exception


SCJP 6 Question 26:SocialTwist Tell-a-Friend

Tuesday, February 8, 2011

SCJP 6 Question 25:

Which of the following are true about the File class ? Select two choices.

A. You can perform file I/O operations using its methods.

B. You can find the size of a file using its size() method.

C. You can check if a file exists using its exists() method.

D. You can delete a file using its delete() method.

SCJP 6 Question 25:SocialTwist Tell-a-Friend

SCJP 6 Question 24:

Consider the following code statement.

Float f = new Float(3.14);

Choose one answer
a. f.parseFloat("2.718")
b. f.valueOf("3.1421")
c. f.byteValue()
d. f.setValue(Math.PI)
e. None of these


SCJP 6 Question 24:SocialTwist Tell-a-Friend

Wednesday, February 2, 2011

Question 23

What will happen when you attempt to compile and run the given code?

public class StringEquals {
  public static void main(String[] args) {
    Boolean b = new Boolean(true);
    String str = new String(""+b);
    StringBuffer sb = new StringBuffer(str);
    System.out.println(b.equals(str)+","
          +str.equals(sb)+","+sb.equals(b));
  }
}
Options:

a. It will print - false, true, false
b. It will print - true, true, false
c. It will print - false, false, false
d. It will print - true, false, false
e. Compilation error
f. ClassCastException at runtime



Question 23SocialTwist Tell-a-Friend