ETEE 3286 Midterm Practice ExamName:______

2. The JVM translates bytecode into machine code. T F

4. The sandbox prevents Java from (choose all the apply):

  1. Writing to the screen
  2. Accessing native program code
  3. Closing your browser
  4. Reading system parameters
  5. Writing to disk

6. Which of the following are the Key Words in the Java Definition?

  1. Simple
  2. Portable
  3. Interpreted
  4. Robust
  5. Dynamic

8. Because of the JVM, your program cannot:

  1. Perform operations that cause errors
  2. Access restricted memory
  3. Call APIs incorrectly
  4. Write to the screen
  5. Call other programs

10. The JVM prevents invasion of system space. T F

12. Servlets are applets that run on Java enabled servers. T F

14. Which of the following is used to convert source codes into bytecodes?

  1. JRE
  2. java
  3. javac
  4. javadoc
  5. JVM

16. Which of the following are included in the Essentials Package?

  1. Objects
  2. Date and time
  3. Threads
  4. Data structures
  5. Strings

18. Programs can be localized for users worldwide using the ______package.

20. The ______package is used to define and run applets.

22 .Sun’s object model is the current standard model. T F

24. Three elements of messages are:

  1. The method to invoke on the target object
  2. The next object to be instantiated
  3. Parameters for the method
  4. Length of the message (in bytes)
  5. The target object

26. The current, standard model for objects is:

  1. The UML
  2. Booch’s Model
  3. The Sun Model
  4. The OSA Model

28. Objects interact by passing messages. T F

30. A source file must:

  1. Have a java extension
  2. Match the class name if only one class declaration exists
  3. Have a class extension
  4. Have a txt extension

32. Braces surround a block of code. T F

34. In the statement: public static void main (String args[ ]), the parentheses around (String args[ ]) indicate:

  1. That args[] is a string
  2. That args[] is an onbject
  3. That main is a method

36. Multi-Line Comments end with:

  1. /*
  2. //
  3. */

38. The println() command:

Is part of the System.out package

Is a method in the out class

Prints a newline character at the end of the line

40. The executable java program has a file extension of _____:

  1. java
  2. class
  3. bin
  4. exe

42. Is the “for” statement valid?

y=5;

for (x=0; x<=y; ++x) {

System.out.println(“X= “+x);

--y;}

  1. Yes
  2. No
  3. Not enough information

44. What is the value of x after this program segment executes?

x=3; y=5

if (x=y) {System.out.println(“X= “+x);

System.out.println(“Y= “+y); }

  1. 3
  2. 4
  3. 5
  4. Not enough information

46. The following statement tests to see if x is equal to y: (x=y) T F

48. How many times will the print statement execute?

for (x=0; x<=5; ++x) System.out.println("X= "+x);

  1. 2
  2. 3
  3. 4
  4. 5
  5. 6

50. How many times will the print statement execute?

for (x=0; x<5; ++x) System.out.println("X= "+x);

  1. 2
  2. 3
  3. 4
  4. 5
  5. 6

52. Boolean data types have a value of 1 or 0. T F

54. float data types are 32 bit real numbers. T F

56. Which of the following are considered whitespace?

  1. Variables
  2. Carriage returns
  3. Keywords
  4. Tabs
  5. Spaces

58. Identifiers may have a preceding underscore. T F

60. bytesare made up of _____ bits?

62. Which of the following are types of integers?

  1. Long
  2. short
  3. float
  4. Byte
  5. int

64. Identifiers may begin with a number. T F

66. Java is case-sensitive. T F

68. In the code below, what will be the final value of y?

double x = 514.2846345238;

byte y;

y = (byte) x;

  1. 514
  2. 512
  3. 2

70. In the code below, what will be the final value of y?

int x = 514;

byte y;

y = (byte) x;

  1. 514
  2. 512
  3. 2

72. What is the value of d after the code has been executed?

int a = -16; b = 7; c = 15; d;

d = a > 2;

  1. 65535
  2. –4
  3. 16
  4. –1

74. What is the value of d after the code has been executed?

boolean a=true, b=true, c=false, d;

d = a & b;

  1. 1
  2. 0
  3. true
  4. false

76. Will a run-time error occur?

int a = 0, b = 10, c;

if (a != 0 & b/a < 1) ...

  1. no
  2. yes
  3. I don’t know

78. What is the value of c after the code has been executed?

int a = 5; b = 7; c;

c = a & b;

  1. 3
  2. 5
  3. 7
  4. 1

80. What is the value of c after the code has been executed?

int a = 5; b = 7; c;

c = a | b;

  1. 3
  2. 5
  3. 7
  4. 1

82. What is the value of c after the code has been executed?

int a = 5; b = 7; c;

c = a ^ b;

  1. 2
  2. 3
  3. 5
  4. 7

84. What is the value of c after the code has been executed?

int a = 1, z;

switch (a) {

case 0: z=2;

case 1: z=1;

case 2: z=0;

}

  1. 0
  2. 1
  3. 2

86. What is the value of c after the code has been executed?

int a = 2, z;

switch (a) {

case 0: z=2; break;

case 1: z=1; break;

case 2: z=0; break;

}

  1. 0
  2. 1
  3. 2

88. What are the values of a and b after execution?

int a = 3, b = 4;

boolean c;

c = (a < b);

if (c) a = 10;

else b = 10;

  1. a=3, b= 4
  2. a=10, b=10
  3. a-10, b=4
  4. a=3, b=10

90. What are the values of a and b after execution?

int a = 3, b = 4;

boolean c;

c = (a < b);

if (c) a = 10;

b = 10;

  1. a=3, b= 4
  2. a=10, b=10
  3. a-10, b=4
  4. a=3, b=10

92. How many times will this loop execute?

int x=0;

while (x == 5){

++x;

}

  1. 0
  2. 1
  3. 4
  4. 5

94. Which of the following may be passed as parameters to a method?

  1. Integers
  2. Arrays
  3. Strings
  4. Methods
  5. Objects

96. The Pass-by-______(value or reference) method may change the value of a variable without returning it to the calling method?

98. For the statement below, which method is executed?

int z = myMethod(w, b);

  1. double myMethod(float x)
  2. int myMethod(int x)
  3. short myMethod(int x, int y)

100. Passing an object as a parameter is an example of pass-by-______.

102. Which access specifier allows class members to be accessed anywhere in your program?

  1. protected
  2. public
  3. private
  4. default

104. Which access specifier relates to inheritance?

  1. protected
  2. public
  3. private
  4. default

106. Which specifier allows access without reference to a specific object?

  1. protected
  2. static
  3. final
  4. default

108. What does the command below do?

anInstanceOfMyClass = new myClass();

  1. declares a reference
  2. assigns a value to a reference
  3. allocates memory for an object

110. Check all that apply to the statement below.

int SqrRoot (float number)

  1. Returns an integer
  2. Defines a new class
  3. Accepts a float as a parameter
  4. Defines a method

112. Which statement must appear in this method?

int SqrRoot(float number)

  1. An “if” clause
  2. A return statement
  3. An assignment statement
  4. Number = ….

114. What is polymorphism?

  1. A big word that I do not understand
  2. One interface, multiple methods
  3. The ability to overload methods and constructors
  4. Duplicate constructors with different parameter lists

116. A superclass can "hide" its members. T F

118. A subclass variable overrides a superclass variable by declaring a variable of the same name. T F