SSD3 Multiple-Choice Quiz 1

Your performance was as follows:

1.

Which method must exist in every Java application?   

 

(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 least two data fields

(b) the Java classes that contain themselves

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

(d) a collection of Java classes that contain 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 will be output by the last statement?

 

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

String s;

int count = 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 Java program 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 program segment.

 

       int x = 5;

       int y = 2;

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

 

Which of the following statements is true about the program segment?

        

 

(a) The output caused by the code will be 512.

(b) The output caused by the code will be 8.

(c) The code will cause a compilation error.

(d) The output caused by the code will be 5 1 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 program segment.

 

    import java.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 concerning the 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 an illegal definition.

(d) x has an illegal definition, but y has a 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 handled are 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.   

         What is 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 a breakpoint, the programmer using the debugger may perform which of the following 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 "The Debugger," 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 it defines, respecting case

(c) must be the same as the class it defines, 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 string concatenation 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 and println of the class java.io.PrintWriter is that

        

 

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

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

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

(d) print inserts a new line at the beginning 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 handle abnormalities in input on Java?

 

(a) By handling these problems by providing exception handlers

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

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

(d) By writing while loops to guard against bad 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 from the 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 true of the conventions outlined by Sun Microsystems in the document entitled Code Conventions for the Java Programming Language?

 

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

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

   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 Code Conventions," in the course notes.

 

   (c)     

 

         10.

        

 

A tool that allows programmers to execute lines of a program one line at a time in order to help locate the source of a program'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 "The Debugger," in the course notes.

 

转载于:https://www.cnblogs.com/vivizhyy/archive/2008/10/27/3394930.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Multiple-Choice Quiz 1 aaaba aadda 1.Which method must exist in every Java application? (a) main (b) paint (c) begin (d) init 2.Which of the following is the string concatenation operator in Java? (a) + (b) ^ (c) & (d) ++ 3.Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement? I. It does not incur run-time overhead. II. It can be used to import multiple packages with a single statement. III. It can be used to import multiple classes with a single statement. (a) I and III only (b) III only (c) I only (d) I, II, and III 4.A difference between the methods print and println of the class java.io.PrintWriter is that (a) print inserts a new line at the beginning of its output, but println does not (b) println appends a new line to the end of its output, but print does not (c) println inserts a new line at the beginning of its output, but print does not (d) print appends a new line to the end of its output, but println does not 5.What will be output when the following Java program segment is executed? int x = 5; int y = 2; System.out.println(x + y);//这种运算是顺序进行的,试试System.out.println(x + y + “1”); (a) 7 (b) 5 2 (c) 5+2 (d) 52 6.What is the right way to handle abnormalities in input on Java? (a) By handling these problems by providing exception handlers (b) By writing while loops to guard against bad input (c) By using the class FileFilter which gracefully filters out bad input data (d) By always specifying the throws clause in every method header where file I/O is performed 7.All Java exception classes are derived from the class (a) java.lang.Throwable (b) java.lang.Error (c) java.io.IOException (d) java.lang.RuntimeException
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值