final java

21
Submitted by Miller, Jean (G00453830) on 11/16/2012 2:59:28 PM Points Awarded 0.0 0 Points Missed 0.0 0 Percentage 0% 1. In the UML, a class’s attributes are placed in the _____ compartment of the class’s rectangle. A) first B) second C) third D) bottom Points Earned: 0.0/ 0.0 Correct Answer(s): B 2. To catch an exception, the code that might throw the exception must be enclosed in a _____. A) throws block B) catch block C) try block D) finally block Points Earned: 0.0/ 0.0 Correct Answer(s): C

Upload: vem

Post on 11-Dec-2015

224 views

Category:

Documents


5 download

DESCRIPTION

notes on exam

TRANSCRIPT

Page 1: Final java

Submitted by Miller, Jean (G00453830) on 11/16/2012 2:59:28 PM

Points Awarded 0.00

Points Missed 0.00

Percentage 0%

1. In the UML, a class’s attributes are placed in the _____ compartment of the class’s rectangle.

A) first

B) second

C) third

D) bottomPoints Earned: 0.0/0.0

Correct Answer(s): B

2. To catch an exception, the code that might throw the exception must be enclosed in a _____.

A) throws block

B) catch block

C) try block

D) finally blockPoints Earned: 0.0/0.0

Correct Answer(s): C

3. The _____ of a class are also called the public services or the public interface that the class provides to its clients.

A) public constructors

B) public instance variables

C) public methods

D) all of the abovePoints Earned: 0.0/0.0

Correct Answer(s): D

Page 2: Final java

4. A default constructor has how many parameters?

A) 0

B) 1

C) 2

D) variablePoints Earned: 0.0/0.0

Correct Answer(s): A

5. An object is an instance of a _____.

A) program

B) class

C) method

D) dataPoints Earned: 0.0/0.0

Correct Answer(s): B

6. You use the keyword _____ to reference a method in the superclass from a subclass.

A) super

B) superObject

C) that

D) thisPoints Earned: 0.0/0.0

Correct Answer(s): A

7. Every class in Java, except _____, extends an existing class.

Page 3: Final java

A) Integer

B) Object

C) String

D) ClassPoints Earned: 0.0/0.0

Correct Answer(s): B

8. Together, the appearance and the way in which the user interacts with the application are known as that application’s _____.

A) abstract window toolkit

B) look-and-feel

C) swing factor

D) All of the abovePoints Earned: 0.0/0.0

Correct Answer(s): B

9. What type of methods allow a client of a class to assign values to a private instance variable?

A) Get methods

B) Replace methods

C) Assign methods

D) Set methodsPoints Earned: 0.0/0.0

Correct Answer(s): D

10. A programmer-defined constructor that has no arguments is called a _____.

A) zero-argument constructor

B) no-argument constructor

C) default constructor

D) main constructor

Page 4: Final java

Points Earned: 0.0/0.0

Correct Answer(s): B

11. Which layout manager is the default for JFrame?

A) FlowLayout

B) BorderLayout

C) GridLayout

D) none of the abovePoints Earned: 0.0/0.0

Correct Answer(s): B

12. The static method _____ of class String returns a formatted String.

A) printf

B) format

C) formatString

D) toFormatStringPoints Earned: 0.0/0.0

Correct Answer(s): B

13. The _____ of a class are also called the public services or the public interface that the class provides to its clients.

A) public constructors

B) public instance variables

C) public methods

D) all of the abovePoints Earned: 0.0/0.0

Correct Answer(s): D

Page 5: Final java

14. An advantage of inheritance is that _____.

A) all methods can be inherited

B) all instance variables can be uniformly accessed by subclasses and superclasses

C) objects of a subclass can be treated like objects of their superclass

D) none of the abovePoints Earned: 0.0/0.0

Correct Answer(s): C

15. The UML represents operations by listing the operation name, followed by a _____-separated list of parameters in parentheses, a _____ and the return type.

A) colon; semicolon

B) colon; colon

C) comma; colon

D) comma; semicolonPoints Earned: 0.0/0.0

Correct Answer(s): C

16. It is a UML convention to denote the name of an abstract class in _____.

A) bold

B) italics

C) a diamond

D) There is no convention of the UML to denote abstract classes—they are listed just as any other class.Points Earned: 0.0/0.0

Correct Answer(s): B

17. What type of methods allow a client of a class to assign values to a private instance variable?

A) Get methods

B) Replace methods

Page 6: Final java

C) Assign methods

D) Set methodsPoints Earned: 0.0/0.0

Correct Answer(s): D

18. In the UML, a class’s attributes are placed in the _____ compartment of the class’s rectangle.

A) first

B) second

C) third

D) bottomPoints Earned: 0.0/0.0

Correct Answer(s): B

19. _____ is invoked to create an object.

A) A constructor

B) The main method

C) A method with a return type

D) A method with the void return typePoints Earned: 0.0/0.0

Correct Answer(s): A

20. Constructors _____.

A) initialize instance variables

B) when overloaded, can have identical argument lists

C) when overloaded, are selected by number, types and order of types of parameters

D) a and cPoints Earned: 0.0/0.0

Correct Answer(s): D

Page 7: Final java

21. UML _____ model several states of an object and show under what circumstances the object changes state.

A) diagrams

B) activity diagrams

C) state machine diagrams

D) machine diagramsPoints Earned: 0.0/0.0

Correct Answer(s): C

22. Which of the following is the superclass constructor call syntax?

A) keyword super, followed by a dot (.)

B) keyword super, followed by a set of parentheses containing the superclass constructor arguments

C) keyword super, followed by a dot and the superclass constructor name

D) none of the abovePoints Earned: 0.0/0.0

Correct Answer(s): B

23. The static method _____ of class String returns a formatted String.

A) printf

B) format

C) formatString

D) toFormatStringPoints Earned: 0.0/0.0

Correct Answer(s): B

24. If the catch-or-declare requirement for a checked exception is not satisfied _____.

Page 8: Final java

A) the compiler will issue an error message indicating that the exception must be caught

B) the compiler will issue an error message indicating that the exception must be caught or declared

C) a stack trace will be displayed indicating the exception that has occurred and where it occurred

D) a stack trace will be displayed, along with a message indicating that the exception must be caughtPoints Earned: 0.0/0.0

Correct Answer(s): B

25. Private fields of a superclass can be accessed in a subclass _____.

A) by calling private methods declared in the superclass

B) by calling public or protected methods declared in the superclass

C) directly

D) all of the abovePoints Earned: 0.0/0.0

Correct Answer(s): B

26. What is the default initial value of a String instance variable?

A) ""

B) "default"

C) default

D) nullPoints Earned: 0.0/0.0

Correct Answer(s): D

27. A constructor cannot _____.

A) be overloaded

B) initialize variables to their defaults

Page 9: Final java

C) specify return types or return values

D) have the same name as the classPoints Earned: 0.0/0.0

Correct Answer(s): C

28. What is best to describe the relationship between a container and a layout manager?

A) association

B) aggregation

C) composition

D) inheritancePoints Earned: 0.0/0.0

Correct Answer(s): B

29. Polymorphism enables you to

A) program in the general

B) program in the specific

C) absorb attributes and behavior from previous classes

D) hide information from the userPoints Earned: 0.0/0.0

Correct Answer(s): A

30. Sending a message to an object means that _____.

A) you call a method of the object

B) you access a variable of the object

C) both (a) and (b)

D) neither (a) nor (b)Points Earned: 0.0/0.0

Correct Answer(s): A

Page 10: Final java

31. What does the equals() method in the Object class return?

A) a boolean indicating whether some other object is equal to this one

B) a zero indicating that the objects are equal

C) an int indicating whether some other object is equal to this one

D) throws an exception indicating that the objects are not equalPoints Earned: 0.0/0.0

Correct Answer(s): A

32. What is the default initial value of a String instance variable?

A) ""

B) "default"

C) default

D) nullPoints Earned: 0.0/0.0

Correct Answer(s): D

33. A default constructor has how many parameters?

A) 0

B) 1

C) 2

D) variablePoints Earned: 0.0/0.0

Correct Answer(s): A

34. When a subclass constructor calls its superclass constructor, what happens if the superclass’s constructor does not assign a value to an instance variable?

A) A syntax error occurs.

B) A compile-time error occurs.

Page 11: Final java

C) A run-time error occurs.

D) The program compiles and runs because the instance variables are initialized to their default values.Points Earned: 0.0/0.0

Correct Answer(s): D

35. Method getFont of class Graphics returns _____.

A) the current font name as a string

B) the font size in points

C) a Graphics object representing the current font

D) a Font object representing the current fontPoints Earned: 0.0/0.0

Correct Answer(s): D

36. The default layout out of a JPanel is _____.

A) FlowLayout

B) GridLayout

C) BorderLayout

D) nonePoints Earned: 0.0/0.0

Correct Answer(s): A

37. It is a UML convention to denote the name of an abstract class in _____.

A) bold

B) italics

C) a diamond

D) There is no convention of the UML to denote abstract classes—they are listed just as any other class.Points Earned: 0.0/0.0

Page 12: Final java

Correct Answer(s): B

38. Attributes of a class are also known as _____.

A) constructors

B) local variables

C) fields

D) classesPoints Earned: 0.0/0.0

Correct Answer(s): C

39. To add a component c to a JPanel p, use _____.

A) p.add(c)

B) p.getContentPane(c)

C) p.insert(c)

D) p.append(c) Points Earned: 0.0/0.0

Correct Answer(s): A

40. A programmer-defined constructor that has no arguments is called a _____.

A) zero-argument constructor

B) no-argument constructor

C) default constructor

D) main constructorPoints Earned: 0.0/0.0

Correct Answer(s): B

41. In the UML, the                 diagram emphasizes which objects participate in collaborations.

Page 13: Final java

A) participation

B) communication

C) collaboration

D) sequence Points Earned: 0.0/0.0

Correct Answer(s): B

42. Which statement is false?

A) The actual data representation used within the class is of no concern to the class’s clients.

B) Clients generally care about what the class does but not how the class does it.

C) Clients are usually involved in a class’s implementation.

D) Hiding the implementation reduces the possibility that clients will become dependent on class-implementation details.Points Earned: 0.0/0.0

Correct Answer(s): C

43. If no exception occurs in a try-catch block, the code in the finally clause _____.

A) is not executed

B) is ignored.

C) is executed

D) may be executedPoints Earned: 0.0/0.0

Correct Answer(s): C

44. An object is an instance of a _____.

A) program

B) class

Page 14: Final java

C) method

D) dataPoints Earned: 0.0/0.0

Correct Answer(s): B

45. The throws clause of a method _____.

A) specifies the exceptions a method catches

B) specifies the exceptions thrown by the calling method

C) specifies the exceptions a method throws

D) specifies the exceptions a method throws and catchesPoints Earned: 0.0/0.0

Correct Answer(s): C

46. Which statement is false?

A) The actual data representation used within the class is of no concern to the class’s clients.

B) Clients generally care about what the class does but not how the class does it.

C) Clients are usually involved in a class’s implementation.

D) Hiding the implementation reduces the possibility that clients will become dependent on class-implementation details.Points Earned: 0.0/0.0

Correct Answer(s): C

47. A Java exception is an instance of _____.

A) RuntimeException

B) Exception

C) Error

D) Throwable. Points Earned: 0.0/0.0

Page 15: Final java

Correct Answer(s): D

48. Exceptions can be thrown by _____.

A) the Java Virtual Machine

B) code in a try block

C) calls from a try block to other methods

D) all of the abovePoints Earned: 0.0/0.0

Correct Answer(s): D

49. A JLabel can be attached to a JFrame using method _____.

A) attach

B) contain

C) append

D) addPoints Earned: 0.0/0.0

Correct Answer(s): D

50. If an exception occurs in a try-catch block, the code in the finally clause _____.

A) is not executed

B) is not executed if the exception is caught.

C) is executed

D) may be executedPoints Earned: 0.0/0.0

Correct Answer(s): C