SSD3 Multiple-Choice Quiz 1

rel="File-List" href="file:///C:%5CUsers%5Cvivi%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"> rel="themeData" href="file:///C:%5CUsers%5Cvivi%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"> rel="colorSchemeMapping" href="file:///C:%5CUsers%5Cvivi%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml">

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.

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. The name of a Java source file (a) has no restrictions (b) must be the same as the class it defines, ignoring case (c) must use the extension .class (d) must be the same as the class it defines, respecting case 2. Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement? Ⅰ.It does not incur run-time overhead. Ⅱ.It can be used to import multiple packages with a single statement. Ⅲ.It can be used to import multiple classes with a single statement (a) I, II, and III (b) I and III only (c) I only (d) III only ..... 9. According to the Java code conventions, files that contain Java source code have the suffix _____, and compiled bytecode files have the suffix _____. (a) .class, .java (b) .class, .javac (c) .java, .class (d) .javac, .class 10. As an aid in debugging a program in Java, print statements may be used to display which of the following types of information? I. The names of methods being called II. The values of the parameters of a method Ⅲ. The values of the instance variables of a class (a) I and II only (b) I and III only (c) II and III only (d) I, II, and III 1. In a UML class diagram's representation of a class, the top, middle, and lower rectangular compartments respectively describe the _____ of the class. (a) name, attributes, and methods (b) name, methods, and constants (c) attributes, methods, and name (d) attributes, methods, and constants 2. UML class diagrams can describe which of the following? I. The internal structure of classes Ⅱ. Relationships between classes (a) I and II (b) II only (c) None (d) I only ....... 1.The term class variable is a synonym for (a) a private data field (b) a static data field (c) a read-only variable (d) an instance variable 2. Consider the following Java program segment. import java.io.*; public class Test { public Test( ) { System.out.println("default"); } public Test( int i ) { System.out.println("non-default"); } public static void main(String[] args) { Test t = new Test(2); } } ......... 9. When a subclass defines an instance method with the same return type and signature as a method in its parent, the parent's method is said to be (a) private (b) hidden (c) overloaded (d) overridden 10. Which is a Java access modifier used to designate that a particular data field will not be inherited by a subclass? (a) final (b) protected (c) private (d) default 1. Consider the following Java program segment. String[] str = {"Three","Two","One"}; for (int i = 0; i < str.length; ++i) { System.out.println(str[i]+"/"); } What will be output upon execution of the program segment? (a) Three/Two/One/ (b) Three,Two,One (c) One,Two,Three (d) One/Two/Three/ 2. Consider the following Java program segment. int[] arr; arr = new int[3]; arr[2]=19; arr[1]=17; arr[0]=15; Which of the following Java statements is syntactically correct and semantically identical to the program segment? (a) int[] arr= {15, 17, 19}; (b) int[3] arr = {15, 17, 19}; (c) int arr = {15, 17, 19}; (d) int arr[3]= {15, 17, 19}; ........ 2. Which of the following statements is (are) true about any abstract method in Java? I. It contains no definition. Ⅱ. It cannot be declared public. (a) I and II (b) I only (c) None (d) II only 3. Consider the following Java program fragment. public void drive(Vehicle v) { ... } ... drive(obj); The method call drive(obj) is valid if obj is which of the following? I. A descendent of class Vehicle II. An ancestor of class Vehicle Ⅲ. An object of class Vehicle (a) I and III only (b) I, II, and III (c) III only (d) II and III only .....

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值