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):
- Writing to the screen
- Accessing native program code
- Closing your browser
- Reading system parameters
- Writing to disk
6. Which of the following are the Key Words in the Java Definition?
- Simple
- Portable
- Interpreted
- Robust
- Dynamic
8. Because of the JVM, your program cannot:
- Perform operations that cause errors
- Access restricted memory
- Call APIs incorrectly
- Write to the screen
- 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?
- JRE
- java
- javac
- javadoc
- JVM
16. Which of the following are included in the Essentials Package?
- Objects
- Date and time
- Threads
- Data structures
- 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:
- The method to invoke on the target object
- The next object to be instantiated
- Parameters for the method
- Length of the message (in bytes)
- The target object
26. The current, standard model for objects is:
- The UML
- Booch’s Model
- The Sun Model
- The OSA Model
28. Objects interact by passing messages. T F
30. A source file must:
- Have a java extension
- Match the class name if only one class declaration exists
- Have a class extension
- 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:
- That args[] is a string
- That args[] is an onbject
- That main is a method
36. Multi-Line Comments end with:
- /*
- //
- */
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 _____:
- java
- class
- bin
- exe
42. Is the “for” statement valid?
y=5;
for (x=0; x<=y; ++x) {
System.out.println(“X= “+x);
--y;}
- Yes
- No
- 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); }
- 3
- 4
- 5
- 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);
- 2
- 3
- 4
- 5
- 6
50. How many times will the print statement execute?
for (x=0; x<5; ++x) System.out.println("X= "+x);
- 2
- 3
- 4
- 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?
- Variables
- Carriage returns
- Keywords
- Tabs
- 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?
- Long
- short
- float
- Byte
- 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;
- 514
- 512
- 2
70. In the code below, what will be the final value of y?
int x = 514;
byte y;
y = (byte) x;
- 514
- 512
- 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;
- 65535
- –4
- 16
- –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
- 0
- true
- false
76. Will a run-time error occur?
int a = 0, b = 10, c;
if (a != 0 & b/a < 1) ...
- no
- yes
- 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;
- 3
- 5
- 7
- 1
80. What is the value of c after the code has been executed?
int a = 5; b = 7; c;
c = a | b;
- 3
- 5
- 7
- 1
82. What is the value of c after the code has been executed?
int a = 5; b = 7; c;
c = a ^ b;
- 2
- 3
- 5
- 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;
}
- 0
- 1
- 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;
}
- 0
- 1
- 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;
- a=3, b= 4
- a=10, b=10
- a-10, b=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;
- a=3, b= 4
- a=10, b=10
- a-10, b=4
- a=3, b=10
92. How many times will this loop execute?
int x=0;
while (x == 5){
++x;
}
- 0
- 1
- 4
- 5
94. Which of the following may be passed as parameters to a method?
- Integers
- Arrays
- Strings
- Methods
- 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);
- double myMethod(float x)
- int myMethod(int x)
- 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?
- protected
- public
- private
- default
104. Which access specifier relates to inheritance?
- protected
- public
- private
- default
106. Which specifier allows access without reference to a specific object?
- protected
- static
- final
- default
108. What does the command below do?
anInstanceOfMyClass = new myClass();
- declares a reference
- assigns a value to a reference
- allocates memory for an object
110. Check all that apply to the statement below.
int SqrRoot (float number)
- Returns an integer
- Defines a new class
- Accepts a float as a parameter
- Defines a method
112. Which statement must appear in this method?
int SqrRoot(float number)
- An “if” clause
- A return statement
- An assignment statement
- Number = ….
114. What is polymorphism?
- A big word that I do not understand
- One interface, multiple methods
- The ability to overload methods and constructors
- 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