Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
javaСЎФсМв_115.doc
Скачиваний:
0
Добавлен:
27.01.2020
Размер:
101.38 Кб
Скачать

SSD3

1. Which is the Java keyword used to denote a class method?

(a) class (b) static (c) private (d) final

2. The term class variable is a synonym for

(a) a read-only variable (b) a private data field

(c) a static data field (d) an instance variable

3. Which of the following statements about class variables in Java is not true?

(a) Non-static methods in a class can access the class variable defined in the same class.

(b) All objects have their own copy of the class variable defined in the instantiated class.

(c) Class variables require the modifier static in the declarations.

(d) Class variables do not need the reference to the object of the instantiated class to access them.

  1. Consider the following UML class diagram.

The diagram describes a

(a) one-to-one relationship (b) relationship between a subclass and a superclass

(c) self-containing class (d) class without methods

5. When using noun-phrase analysis to model a software system, which of the following should typically be eliminated from the list of potential classes?

I .References to the software system itself

II .Nouns that imply roles between objects

III .Synonyms to other nouns in the list

(a) I and III only (b) I, II, and III (c) III only (d) II and III only

6. Which of the following statements about constructors in Java is true?

(a) A class must define at least one constructor.

(b) A class can define more than one constructor.

(c) A constructor must be defined as static.

(d) A constructor must be defined as public.

7. If a(n) _____ exception can occur in a method that does not have a catch block to handle that exception, then a throws clause that lists this exception must be part of the method _____.

(a) unchecked, body (b) checked, body (c) checked, header (d) unchecked, header

8. If a class contains a constructor, that constructor will be invoked

(a) once at the beginning of any program that uses that class

(b) each time an object of that class is instantiated

(c) once the first time an object of that class is instantiated

(d) each time an object of that class goes out of scope

9. 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);

}

}

Which of the following will be output during execution of the program segment?

(a) The line of text "default"

(b) The line of text "default" followed by the line of text "non-default"

(c) The line of text "non-default" followed by the line of text "default"

(d) The line of text "non-default"

10. From within a child class, its parent class is referred to via the keyword

(a) super (b) this (c) parent (d) base

11. Which of the following statements imports the entire package java.Util into a Java program? (a) import util; (b) import util.*; (c) import java.Util.*; (d) import java.Util;

12. Consider the following Java class definitions.

public class Object1 {

protected String d(){

return "Hi";

}

}

public class Object2 extends Object1 {

protected String d(){

return super.d();

}

}

Which of the following statements is (are) true regarding the definitions?

I .Class Object2 inherits from class Object1.

II .Class Object2 overrides method d.

III .Method d returns equivalent results when executed from either class.

(a) I, II, and III (b) I and II only (c) I and III only (d) III only

13. After a breakpoint is hit, a debugger is typically used for which of the following tasks?

I. Stepping through method calls, line by line II. Examining a stack trace

III. Examining values of variables in the current method

(a) I and III only (b) I and II only (c) II only (d) I, II, and III

14. Which is a Java access modifier used to designate that a particular data field will not be inherited by a subclass?

(a) private (b) final (c) protected (d) default

15. If the method int sum(int a, int b) is defined in a Java class C, which of the following methods cannot coexist as a different method in class C?

(a) int sum(int x, float y) (b) int sum(float a, int b)

(c) float sum(int x, float y) (d) int sum(int x, int y)

16. 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) has no restrictions

(d) must be the same as the class it defines, ignoring case

17. Which package does not need to be explicitly imported into a Java program?

(a) java.io (b) java.lang (c) java.applet (d) java.awt

18. Given the following code, how many tokens will be output?

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

while (st.hasMoreTokens()) {

stdOut.println(st.nextToken() );

}

(a) 1 (b) 0 (c) 4 (d) 3

19. Consider an object stdIn instantiated by the Java statement below.

private static java.io.BufferedReader stdIn =

new java.io.BufferedReader(

new java.io.InputStreamReader(System.in));

Which of the following lines of code can be used to read an integer value from stdIn?

(a) int value = stdIn.readInteger(); (b) int value = Integer.parseInt(stdIn.readLine());

(c) int value = stdIn.readLine(); (d) int value = Integer.parseInt(stdIn);

20. What will be output when the following Java program segment is executed?

int x = 5;

int y = 2;

System.out.println(x + y);

(a) 7 (b) 52 (c) 5 2 (d) 5+2

21. 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 inserts a new line at the beginning of its output, but print does not

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

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

22. In Java, exceptions that are not handled are passed up the

(a) block hierarchy (b) call stack (c) exception ladder (d) catch blocks

23. All Java exception classes are derived from the class

(a) java.lang.Error (b) java.lang.Throwable

(c) java.io.IOException (d) java.lang.RuntimeException

24. Which of the following is true regarding Java applications?

(a) They are platform-dependent. (b) They are compiled into machine code.

(c) They are interpreted by a Web browser. (d) They are run using a Java interpreter.

25. Which method must exist in every Java application?

(a) main (b) paint (c) begin (d) init

26. 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, II, and III (b) III only (c) I only (d) I and III only

27. 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

28. What is the name of the JDK program that processes Javadoc comments?

(a) java (b) javac (c) javacom (d) javadoc

29. 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) scope (b) exception handler (c) debugger (d) stack trace

30. UML class diagrams can describe which of the following?

I .The internal structure of classes

II .Relationships between classes

(a) I only (b) I and II (c) II only (d) None

31. When using a debugger to step through a program, if the current line contains a method call, which of the following executes the current line and then stops execution before executing the first line in the called method?

(a) step return (b) resume (c) step into (d) step over

32. According to Javadoc convention, the first sentence of each Javadoc comment should be

(a) a summary sentence of the declared entry (b) an @author tag

(c) the order of lines is not important (d) an @version tag

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

(a) 100, encouraged (b) 100, avoided (c) 2000, encouraged (d) 2000, avoided

34. 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

III .The values of the instance variables of a class

(a) II and III only (b) I and III only (c) I and II only (d) I, II, and III

35. In a UML diagram, a specialization/generalization relationship is characterized by a line between two classes and a _____ next to the _____ class.

(a) triangle, generalization (b) triangle, specialization

(c) diamond, specialization (d) diamond, generalization

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]