27
University of Central Florida COP 3330 Object Oriented Programming 1. Operators are special symbols that perform specific operations on up to how many operands? a. One b. Two c. Three d. Four e. None 2. Regarding operator precedence which of the following would be evaluated first? a. = b. * c. + d. instanceof e. ++ 3. What is the purpose of the assignment operator? a. Assigns the value on the left to the operand on the right b. Assigns the value on the right to the operand on the left c. To check for equality d. To check for identical e. None of the above 4. The + operator performs two operations, which of the following is true? a. Assignment b. Concatenation c. Addition

UCF  · Web viewOperators are special symbols that perform specific operations on up to how many operands?. One. Two. Three. Four. None. Regarding operator precedence which of the

Embed Size (px)

Citation preview

University of Central Florida

COP 3330 Object Oriented Programming

1. Operators are special symbols that perform specific operations on up to how many operands?

a. Oneb. Twoc. Threed. Foure. None

2. Regarding operator precedence which of the following would be evaluated first?

a. =b. *c. +d. instanceofe. ++

3. What is the purpose of the assignment operator?a. Assigns the value on the left to the operand on the rightb. Assigns the value on the right to the operand on the leftc. To check for equalityd. To check for identicale. None of the above

4. The + operator performs two operations, which of the following is true?a. Assignmentb. Concatenationc. Additiond. A and Ce. B and C

5. How many operands do unary operators require?a. Oneb. Two c. Threed. Foure. None

2

6. Regarding conditional operators (i.e. &&, ||) what does “short circuiting” behavior mean?

a. Both operands/expressions are evaluatedb. Only the second operand/expression is evaluatedc. Only the first operand/expression is evaluatedd. The second operand/expression is evaluated only if needede. None of the operands/expressions are evaluated

7. What does the instanceof operator do?

a. Tests if the compared operands are equalb. Tests if the compared operands are identicalc. Tests if the expression is trued. Tests if the expression is falsee. Tests if the object is an instance of a class, subclass, or

implements an interface

8. A(n) ________ comprises variables, operators, and method invocations.a. Expressionb. Statementc. Abstract classd. Classe. Interface

9. A(n) ________ forms a complete unit of execution to include a terminating

semicolon.a. Expressionb. Expression statementc. Abstract classd. Classe. Interface

10. A(n) ________ declares a variable.a. Expressionb. Expression statementc. Declaration statementd. Classe. Interface

11. What is used in programming to block a group of zero or more executable statements?

a. []b. ()c. <>d. {}e. /* */

3

12. What is the purpose of control flow statements?a. To allow programs to run sequentiallyb. To allow programs to run line by line from top to bottomc. To allow programs to run with a break up of execution flow d. All of the abovee. None of the above

13. If a programmer writes a control flow statement using if – else if – else if –else if… are they required to include an else leg?

a. Yesb. No

14. If a programmer writes a control flow statement using switch… are they required to include a default case label?

a. Yesb. No

15. Regarding classes, instance variables are __________.a. Staticb. Non-staticc. Both A and Bd. None of the above

16. Regarding classes, class variables are __________.a. Staticb. Non-staticc. Both A and Bd. None of the above

17. Local variables store a __________ state.a. Permanentb. Staticc. Instanced. Temporarye. None of the above

18. Parameters are different than arguments because parameters are used when __________.

a. A method or constructor is definedb. A method or constructor is calledc. A class is definedd. An interface is definede. An abstract class is defined

19. Parameters are different than arguments because arguments are used when __________.

4

a. A method or constructor is definedb. A method or constructor is calledc. A class is definedd. An interface is definede. An abstract class is defined

5

20. Variable naming has rules associated with it. Which of the following is true?

a. They can start with a numberb. They can start with any special characterc. They can include white spaced. All of the above e. None of the above

21. In object-oriented terms what is used as a blueprint to model a real-world object?

a. Methodb. Statec. Behaviord. Constante. Class

22. Object-oriented programming allows for inheritance so commonly used state and behavior can be reused. The class that is inherited from is the __________ and the new class is the __________.

a. Superclass, subclassb. Subclass, superclassc. Interface, subclassd. Class, packagee. Extends, implements

23. How many superclasses can a subclass extend when using inheritance in object-oriented programming using the Java programming language?

a. Zerob. Onec. Twod. Threee. Unlimited

24. When using inheritance what does the new class inherit when it is derived from another class?

a. State, behaviorb. Object, classc. Inheritance, interfaced. Function, methode. Project, package

25. When implementing an interface in object-oriented programming all __________ must be included in the source code for the class to compile.

a. Stateb. State and behaviorc. Superclasses

6

d. Constructorse. Methods

7

26. An expression statement forms a complete unit of execution with a terminating semicolon. The following code is a correct example of an expression statement: Game game = new Game();

a. Trueb. False

27. Does the following code include all required components for a class declaration?

public class NewClass{}

a. Yesb. No, it’s missing the fields and methodsc. No, the access modifier is not requiredd. No, it’s missing the return typee. No, it’s missing the parentheses and parameter list

28. What are the components of a method declaration that comprise the

method signature?a. Method return type and method nameb. Method return type and method parameter listc. Method return type, method name, and method parameter listd. Method name and method parameter liste. All of the above

29. Does the following code include all required components for a method declaration?

void thisMethod(){}

a. Yesb. No, it’s missing the access modifierc. No, it’s missing the return typed. No, it’s missing the parameter liste. No it’s missing the argument list

30. Which of the following are types of class member variables?a. Fieldsb. Local variablesc. Parametersd. All of the abovee. None of the above

8

31. The object-oriented concept of software reuse allows a class to be created once and used __________.

a. Neverb. Once unless it is extended using inheritancec. As many times as desired to include extending it using

inheritanced. Ten times or lesse. Once unless it is implemented using interface

32. If a class explicitly declares a constructor that takes 0…n parameters when instantiated what happens to the default constructor of the class?

a. It still exists and can be used to create instances of the classb. It is automatically created by the Java compilerc. It no longer existsd. All of the abovee. None of the above

33. When does a method return to the code that invoked it?a. Completes all the statements in the methodb. Reaches a return statementc. Throws an exceptiond. A or Be. A, B, or C

34. What is the automatic access modifier of methods and fields of an

interface?a. Packageb. Publicc. Package-privated. Privatee. Protected

35. What does the keyword final indicate regarding methods or field members of a class?

a. They cannot be modifiedb. They are publicc. They are privated. They are modifiablee. None of the above

36. If there are an unknown number of parameters being passed to a method a software developer can use a construct called __________.

a. varargsb. an arrayc. an ArrayListd. a 2-d array

9

e. None of the above

37. The ternary operator takes three operands and uses the (?:) notation. What control structure does the ternary operator mimic?

a. If/elseb. While loopc. Switchd. For loope. Do/while loop

10

38. Regarding object-oriented programming, declaration means that a variable name is associated with an object type and creates an object of that type.

a. Trueb. False

39. When method parameters have the same name as class fields this is called __________.

a. Repetitionb. Duplicationc. Same named. Shadowinge. Confusion

40. When having to programmatically differentiate a parameter having the same name as a field of a class what keyword can resolve this issue with the compiler when setting the field value equal to the argument value passed into the method?

a. keywordb. thisc. parameterd. argumente. in

41. Regarding object-oriented programming, when an object is instantiated the keyword new is used, memory is allocated, and a reference to that memory is returned.

a. Trueb. False

42. An interface can and should be instantiated.

a. Trueb. False

43. A method in object oriented programming can return primitive data types, __________, or __________.

a. Project, packageb. Function, methodc. Constructor, exceptiond. Class, interfacee. Code, return

44. The keyword this is used to reference __________.a. The inheritanceb. The interfacec. The subclass

11

d. The current objecte. The class’s destructor

12

45. Operators with higher precedence are evaluated __________ operators with relatively __________ precedence

a. After, lowerb. Before, higherc. Before, lowerd. After, highere. None of the above

46. When defining classes in the Java programming language a software developer can extend __________ superclasses and implement __________ interfaces.

a. Unlimited, oneb. Two, unlimitedc. One, unlimitedd. Unlimited, twoe. Unlimited, unlimited

47. A class that uses an explicit constructor invocation uses the keyword this to __________.

a. Call another constructor in the same class b. Call the super constructorc. User recursion and call itselfd. Call another constructor in a different classe. Call the constructor of the implemented interface

48. When a method has a return type other than void what data type can be returned from that method?

a. No return value is requiredb. The returned data type can be any data type valid in the Java

programming languagec. The returned data type must match the declared return data

typed. The returned data type should be Stringe. None of the above

49. What allows for methods to have the same name but different method signatures in object oriented programming?

a. Class overridingb. Method overridingc. Class overloadingd. Method overloadinge. Shadowing

50. What differentiates methods with the same name in a class?a. Return typeb. Access modifier

13

c. Argument listd. Parameter liste. None of the above, this is not permitted

14

51. Access level modifiers do not define how other classes can reference a field or invoke a method.

a. Trueb. False

52. A class can have multiple constructors.a. Trueb. False

53. Encapsulation of class fields hides implementation details. How is encapsulation used to access fields of classes?

a. Private methods are written to interact with the private fieldsb. Public methods are written to interact with the public fields c. Private methods are written to interact with the public fieldsd. Public methods are written to interact with the private fieldse. None of the above, encapsulation is not a real topic in object

oriented programming

54. In object oriented programming classes, keywords, methods, variables, and interfaces are not case sensitive.

a. Trueb. False

55. What is a key difference between an if/else if/else and a switch control flow statement?

a. switches stop evaluating when it finds a true conditionb. if/else if/else stop evaluating when it finds a true conditionc. Both stop evaluating when it finds a true conditiond. if/else if/else continues evaluating after it finds a true conditione. None of the above, there is no difference

56. Regarding file pathing there are two options, absolute and relative. Which of the following statements is true?

a. Absolute never includes the root element and the complete directory list required to access the file

b. Relative needs to be combined with another path to access the file

c. Absolute needs to be combined with another path to access the file

d. Relative always includes the root element and the complete directory list required to access the file

e. There is no difference

15

57. Given the source code above, where is method populateDice() defined?

a. In class ReadDataFileb. In the Java APIc. In interface Boardd. In class Boarde. In interface ReadDataFile

58. Given the source code above, what is ReadDataFile(dataFileName)?

a. A destructorb. A makerc. A custom constructord. A default constructore. A no-argument constructor

59. Given the source code above, what is JOptionPane.showMessageDialog(null, “Let’s Play Boggle!”)?

a. A non-static methodb. A static methodc. An instance methodd. A class methode. None of the above

60. Given the source code above, can the method signature public static void main (String[] args) be changed?

a. No, it is required by the JVMb. Yes, the return type can be any data typec. Yes, the parameter list can be modifiedd. No, it is required by the operating systeme. Yes, it doesn’t have to be a static method

16

61. Given the source code above, regarding public static void main (String[] args), what is args?

a. A member variableb. An instance variablec. A primitive data typed. A local variablee. A class

62. Given the source code above, what is ReadDataFile?a. A member variableb. An instance variablec. A primitive data typed. An interfacee. A class

63. Given the source code above what are data and dictionary?a. Member variablesb. Instance variablesc. Reference objectsd. Local variablese. Classes

64. Given the source code above what is IDie?a. A classb. A Java API classc. An interfaced. A methode. A member variable

65. Given the source code above, what is NUMBER_OF_SIDES?a. A member variableb. An instance variablec. A class variabled. A static variablee. A constant

17

18

66. Given the source code above, should the methods include a method body?

a. No, interfaces don’t include method bodiesb. Yes, interfaces should include method bodies

67. Given the source code above, can a programmer instantiate an instance of interface IDie?

a. Yesb. No

68. Given the source code above, what is it called when a class implements an interface such as in Die implements IDie?

a. Subclassingb. Superclassingc. Inheritanced. Implementatione. Interfacing

69. Given the source code above, where was method signature public String rollDie() defined?

a. In class Dieb. In the Java APIc. In class Boardd. In interface IBoarde. In interface IDie

19

70. Given the source code above, can the method signature public void addLetter(String letter) be modified in class Die?

a. Yesb. No

71. Given the source code above, where is the method .add(letter) in code letters.add(letter) defined?

a. In interface IDieb. In Java API for class ArrayListc. In class Boardd. In interface IBoarde. In class ReadDataFile

72. Given the source code above, what type of looping is being used in expression for(String value : letters)?

a. Traditional for loopb. Enhanced for loopc. While loopd. Do/while loope. None of the above

73. Given the source code above, what data type of objects can be added to ArrayList member variable letters?

a. Stringb. Diec. Boardd. inte. Anything

74. The content pan of a top-level container (i.e. JFrame, JDialog, JApplet) is the container where the root pane’s visible components are comprised, excluding the __________.

a. JMenuBarb. JPanelc. JLabeld. JButton

75. An ActionListener is equivalent to an event handler.a. Trueb. False

76. When writing an ActionListener there are specific steps that should be followed. Select the correct combination of steps.

a. Declare an event handler class that implements the ActionListener interface

b. Register an instance of the defined event handler class on one or more components

20

c. Ensure the class that implements interface ActionListener includes method public void actionPerformed(ActionEvent e){}

d. A, B, and C

77. The javax.swing and javax.swing.event, or Swing API, has 18 public packages that group features for developing user interfaces, this is known as part of the __________.

a. Java 2D APIb. Visual Studioc. User Interface Package (UIP)d. Java Foundation Classes (JFC)

78. JDialog is one of the three top-level containers.a. Trueb. False

79. GridBagLayout layout manager uses __________ to specify the size and position characteristics of its components.

a. BorderLayoutb. JTablec. GridLayoutd. GridBagConstraints

80. Which Java programming language layout manager arranges the components into rows and columns using equal-sized rectangular grid?

a. BorderLayoutb. GridLayoutc. FlowLayoutd. CardLayout

81. GridBagLayout layout manager allows for components to span multiple rows and columns.

a. Trueb. False

82. When adding components to a JPanel using the FlowLayout layout manager how are the components placed if not specified?

a. Bottom to top in the order they were addedb. Top to bottom in the order they were addedc. Right to left in the order they were addedd. Left to right in the order they were added

83. Which layout manager is the default layout for class javax.swing.JPanel?

a. GridLayoutb. FlowLayout

21

c. BorderLayoutd. GridbagLayout

84. BoxLayout allows the developer to do which of the following?a. Put components only in single rows, columns are not an optionb. Forces components to display in equal sizec. Align componentsd. All of the above

85. GridBagLayout is the most flexible layout manager as well as one of the most simple.

a. Trueb. False

86. CardLayout allows for implementing an area that contains different components at different times.

a. Trueb. False

87. Two of the six layout managers provided by the Java API were designed with the intent to use them with GUI builder tools, they are __________ and __________.

a. BoxLayout, CardLayoutb. GroupLayout, GridbagLayoutc. SpringLayout, GroupLayoutd. GroupLayout, FlowLayout

88. Which layout manager is the default layout for the three top-level container classes in the javax.swing package?

a. GridLayoutb. FlowLayoutc. BorderLayoutd. GridbagLayout

89. When using FlowLayout, if the width of a container is not wide enough to accommodate all the components in a single row how does the layout manager respond?

a. No more components displayb. Starts a new row c. Overlays new components on existing componentsd. None of the above

22

90. The layout above that places components in five specific areas is representative of which layout manager?

a. BorderLayoutb. BoxLayoutc. CardLayoutd. FlowLayout

91. A popup menu bar is __________ until the user invokes the appropriate commands to make it appear?

a. Invisibleb. Dockedc. Visibled. None of the above

92. To add a clickable button to a user interface the javax.swing class JButton is commonly used. Which of the following statements is true about the class JButton?

a. Unlike the JMenu class the JButton class cannot use mnemonics. b. The JButton class only allows for displaying text on the buttonc. The JButton class has automatic event handling associated with

it when clickedd. A JButton instance can display its text in a different place

relative to its image

93. The purpose of writing ActionListeners is to define what code should be executed when the application fires a specific ActionEvent.

a. Trueb. False

94. Each of the three top level container classes has a content pane that contains the visible components in its container user interface.

a. Trueb. False

23

95. actionPerformed(ActionEvent) is the only method that is required to be implemented when implementing the ActionListener interface in Java.

a. Trueb. False

96. Menus in the Java programming language are unique as they aren’t placed with the other components in the user interface.

a. Trueb. False

97. With the exception of the three top-level containers all Swing components that start with the letter “J” descend from the __________ class.

a. JComponentb. JObjectc. JTextComponent d. JFrame

98. The layout above that displays components from left to right in the order they were added to the user interface is representative of which layout manager?

a. BorderLayoutb. BoxLayoutc. CardLayoutd. FlowLayout

99. The layout above that displays components in a row/column format with each component being of equal size is representative of which layout manager?

24

a. BorderLayoutb. GridLayoutc. CardLayoutd. FlowLayout

100. In the Java 2D API an image is typically a. a rectangular two-dimensional array of pixelsb. each pixel represents the color at that position of the imagec. the dimensions represent the width and height of the imaged. All of the abovee. None of the above

101. Image I/O has built-in support for GIF, PNG, JPEG, BMP, and WBMP.

a. Trueb. False

102. Many Swing components, such as labels, buttons, and tabbed panes, can be decorated with an icon

a. Trueb. False