SCJP真题库更新20

QUESTION 96

Given:

What is the result? 

A. Compilation fails

B. Pi is approximately 3.

C. Pi is approximately 3.141593.

D. An exception is thrown at runtime.

 

Answer: ( D )

%d打印一个整数,要求接受一个整数 IllegalFormatConversionException

 

QUESTION 97

Given:

What is the result?

A. int Long

B. Short Long

C. Compilation fails

D. An exception is thrown at runtime.

 

 

Answer: ( A )

 

QUESTION 98

Chain these constructors to create objects to read from a file named "in" and to

write to a file named "out".

Answer: (  )

new BufferedReader( new FileReader( “in”));

new PrintWriter( new BufferedWriter( new FileWriter( “out”)));

 

QUESTION 99

Place the code fragments into position to use a BufferedReader to read in an entire text file.

Answer: (  )

class PrintFile{

        public static void main(String[] args){

                BufferedReader buffReader = null;

                //more code here to initialize buffReader

                try{

                        String temp;

                        while((temp=buffReader.readLine()) !=null){

                                System.out.println(temp);

                        }

                }catch  (IOException e){

                        e.printStackTrace();

                }

        }

}

 

 

QUESTION 100

Given this method in a class:

 

Which statement is true? 

A. This code is NOT thread-safe.

B. The programmer can replace StringBuffer with StringBuilder with no other changes.

C. This code will perform poorly. For better performance, the code should be rewritten:

return "<" + this.name + ">";

D. This code will perform well and converting the code to use StringBuilder will not

enhance the performance.

 

 

Answer: ( B )

你可能感兴趣的:(scjp,真题)