Third Quarter Exam Computer Programming (Java)
Third Quarter Exam Computer Programming (Java)
Department of Education
Tarlac City Schools Division
TIBAG HIGH SCHOOL
(Formerly Maliwalo National High School-Annex)
Tibag, Tarlac City
____3.With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?
1. x++;
2. x = x + 1;
3. x += 1;
4. x =+ 1;
A. 1, 2 & 3 B. 1 & 4 C. 1, 2, 3 & 4 D. 3 & 2
____13. An expression involving byte, int, and literal numbers is promoted to which of these?
A. int B. long C. byte D. float
____14. Which data type value is returned by all transcendental math functions?
A. int B. float C. double D. long
____16. Which of these coding types is used for data type characters in Java?
A. ASCII B. ISO-LATIN-1 C. UNICODE D. None of the mentioned
____26. To prevent any method from overriding, we declare the method as,
A. static B. const C. final D. abstract
____34. What is the type and value of the following expression? (Notice the integer division)
-4 + 1/2 + 2*-3 + 5.0
A. int -5 B. double -4.5 C. int -4 D. double -5.0
____35. What is printed by the following statement? System.out.print(“Hello,\nworld!”);
A. Hello, \nworld! B. Hello, world! C.Hello D. “Hello, \nworld!”
world!
____36. Consider the two methods (within the same class)
public static int foo(int a, String s)
{
s = “Yellow”;
a=a+2;
return a;
}
public static void bar()
{
int a=3;
String s = “Blue”;
a = foo(a,s);
System.out.println(“a=”+a+” s=”+s);
}
public static void main(String args[])
{
bar();
}
What is printed on execution of these methods?
A. a = 3 s = Blue B. a = 5 s = Yellow C. a = 3 s = Yellow D. a = 5 s = Blue
____37. Which of the following variable declaration would NOT compile in a java program?
A. int var; B. int VAR; C. int var1; D. int 1_var;.
____40. A constructor
A. Must have the same name as the class it is declared within.
B. Is used to create objects.
C. May be declared private
D. A., B. and C. above.
____41. Consider,
public class MyClass
{
public MyClass(){/code/}
// more code…
}
To instantiate MyClass, you would write?
A. MyClass mc = new MyClass(); B. MyClass mc = MyClass();
C. MyClass mc = MyClass; D. MyClass mc = new MyClass;.
____44. You read the following statement in a Java program that compiles and executes.
submarine.dive(depth);
What can you say for sure?
A. depth must be an int B. dive must be a method.
C. dive must be the name of an instance field. D. submarine must be the name of a class
___45. The java run time system automatically calls this method while garbage collection.
A. finalizer() B. finalize() C. finally() D. finalized()
Prepared by:
Noted: