SSD3 Multiple-Choice Quiz 1

来源:互联网 发布:网络电话卡代理 编辑:程序博客网 时间:2024/06/06 08:36

Your performance was as follows:

1.

Which method must exist in every Javaapplication?   

 

(a) begin

(b) main

(c) paint

(d) init

 

Correct answer is   (b)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.1 of the course notes.

  (b)    

 

         2.  

The term wrapper classes refers to      

 

(a) the Java classes that contain at leasttwo data fields

(b) the Java classes that containthemselves

(c) a collection of Java classes that"wrap" Java primitive types

(d) a collection of Java classes thatcontain other Java classes

 

Correct answer is   (c)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.3 of the course notes.

  (c)     

 

         3.  

Given the following code, what value willbe output by the last statement?

 

StringTokenizerst = new StringTokenizer("this is,a,test of tokens", ",");

Strings;

intcount = 0;

 

while(st.hasMoreTokens())  {

      s = st.nextToken();

      ++count;

}

stdOut.println(count);

 

        

 

(a) 3

(b) 1

(c) 6

(d) 4

 

Correct answer is (a)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.3 of the course notes.

  (a)    

 

         4.  

        

 

What will be output when the following Javaprogram segment is executed?

 

      int x = 5;

      int y = 2;

      System.out.println(x + y);

 

        

 

(a) 5+2

(b) 5 2

(c) 7

(d) 52

 

Correct answer is   (c)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.4 of the course notes.

  (c)     

 

         5.  

        

 

Consider the following Java programsegment.

 

      int x = 5;

      int y = 2;

      System.out.println(x + "1" + y);

 

Which of the following statements is trueabout the program segment?

        

 

(a) The output caused by the code will be512.

(b) The output caused by the code will be8.

(c) The code will cause a compilationerror.

(d) The output caused by the code will be 51 2.

 

Correct answer is (a)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.4 of the course notes.

  (a)    

 

         6.  

        

 

Consider the following Java programsegment.

 

    importjava.io.*;

 

   public class SomeClass{

 

     public void x() {

 

          throw new RuntimeException("Exception from x");

     }

     

     public void y(){

 

          throw new IOException("Exception from y");

     }

    }

 

Which of the following is true concerningthe definitions for the methods x and y?

        

 

(a) Neither x nor y has a legal definition.

(b) Both x and y have legal definitions.

(c) x has a legal definition, but y has anillegal definition.

(d) x has an illegal definition, but y hasa legal definition.

 

Correct answer is   (c)

 

Your score on this question is:        0.00

 

Feedback:       

  See section 1.1.5 of the course notes.

  (b)    

 

         7.  

        

 

In Java, exceptions that are not handledare passed up the

        

 

(a) exception ladder

(b) call stack

(c) catch blocks

(d) block hierarchy

 

Correct answer is   (b)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.5 of the course notes.

  (b)    

 

         8.  

         Whatis the name of the JDK program that processes Javadoc comments?        

 

(a) javadoc

(b) javacom

(c) javac

(d) java

 

Correct answer is (a)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.7 of the course notes.

  (a)    

 

         9.  

        

 

According to the Java code conventions,files longer than _____ lines should be _____.

        

 

(a) 2000, encouraged

(b) 100, encouraged

(c) 2000, avoided

(d) 100, avoided

 

Correct answer is   (c)

 

Your score on this question is:        0.00

 

Feedback:       

  

 

See section 1.1.6, subsection"CodeConvTOC," in the course notes.

 

  (d)    

 

         10.

        

 

After a typical debugger encounters abreakpoint, the programmer using the debugger may perform which of thefollowing actions?

 

   1.Examine the values of variables in the halted program

   2.Execute the current line

   3.Resume execution of the halted program

 

        

 

(a) III only

(b) I, II, and III

(c) I only

(d) I and II only

 

Correct answer is   (b)

 

Your score on this question is:        0.00

 

Feedback:       

  

 

See section 1.1.8, subsection "TheDebugger," in the course notes.

 

  (d)    

 

         1.  

The name of a Java source file       

 

(a) must use the extension .class

(b) must be the same as the class itdefines, respecting case

(c) must be the same as the class itdefines, ignoring case

(d) has no restrictions

 

Correct answer is   (b)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.1 of the course notes.

  (b)    

 

         2.  

        

 

Which of the following is the stringconcatenation operator in Java?

        

 

(a) +

(b) ++

(c) ^

(d) &

 

Correct answer is   (a)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.3 of the course notes.

 

         5.  

        

 

A difference between the methods print andprintln of the class java.io.PrintWriter is that

        

 

(a) println appends a new line to the endof its output, but print does not

(b) print appends a new line to the end ofits output, but println does not

(c) println inserts a new line at thebeginning of its output, but print does not

(d) print inserts a new line at thebeginning of its output, but println does not

 

Correct answer is   (a)

 

Your score on this question is:        10.00

 

Feedback:       

  See section 1.1.4 of the course notes.

  (a)    

 

         6.  

What is the right way to handleabnormalities in input on Java?

 

(a) By handling these problems by providingexception handlers

(b) By always specifying the throws clausein every method header where file I/O is performed

(c) By using the class FileFilter whichgracefully filters out bad input data

(d) By writing while loops to guard againstbad input

 

Correct answer is   (a)

 

Your score on this question is:        0.00

 

Feedback:       

  See section 1.1.5 of the course notes.

  (b)    

 

         7.  

        

 

All Java exception classes are derived fromthe class

        

 

(a) java.lang.RuntimeException

(b) java.lang.Throwable

(c) java.lang.Error

(d) java.io.IOException

 

Correct answer is   (b)

 

Your score on this question is:        0.00

 

Feedback:       

  See section 1.1.5 of the course notes.

  (a)    

 

         9.  

        

 

Which of the following statements is trueof the conventions outlined by Sun Microsystems in the document entitled CodeConventions for the Java Programming Language?

 

   1.They define a standard interface definition language that must be used for allJava classes.

   2.They provide recommendations intended to make source code easier to read andunderstand.

   3.They describe one mechanism for network communication between Java and C++programs.

 

        

 

(a) III only

(b) I, II, and III

(c) II only

(d) I and III only

 

Correct answer is   (c)

 

Your score on this question is:        10.00

 

Feedback:       

  

 

See section 1.1.6, subsection"CodeConvTOC" and section 1.1, subsection "Why Have CodeConventions," in the course notes.

 

  (c)     

 

         10.

        

 

A tool that allows programmers to executelines of a program one line at a time in order to help locate the source of aprogram's errors is known as a(n)

        

 

(a) debugger

(b) stack trace

(c) exception handler

(d) scope

 

Correct answer is   (a)

 

Your score on this question is:        10.00

 

Feedback:       

  

 

See section 1.1.8, subsection "TheDebugger," in the course notes.

 

原创粉丝点击