You are on page 1of 5

Republic of the Philippines

Department of Education
Tarlac City Schools Division
TIBAG HIGH SCHOOL
(Formerly Maliwalo National High School-Annex)
Tibag, Tarlac City

THIRD QUARTERLY ASSESSMENT


(SY:2018-2019)
________________
Parent’s Signature
Name:__________________ Date:______________
Section:_________________ Score:_____________

____1. Which of the following can be operands of arithmetic operators?


A. Numeric B. Boolean C. Characters D. Both Boolean & Characters

____2. Modulus operator, %, can be applied to which of these?


A. Integers B. Floating – point numbers C. Both Integers and floating – point numbers. D. None of the mentioned

____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

____4. Decrement operator, –, decreases value of variable by what number?


A. 1 B. 2 C. 3 D. 4

____5. Which of these statements are incorrect?


A. Assignment operators are more efficiently implemented by Java run-time system than their equivalent long forms.
B. Assignment operators run faster than their equivalent long forms.
C. Assignment operators can be used only with numeric and character data type.
D. None

____6. What is the output of this program?


class increment {
public static void main(String args[])
{
double var1 = 1 + 5;
double var2 = var1 / 4;
int var3 = 1 + 5;
int var4 = var3 / 4;
System.out.print(var2 + " " + var4);}
}
A. 1 1 B. 0 1 C. 1.5 1 D. 1.5 1.0

____7. What is the output of this program?


class Modulus {
public static void main(String args[])
{
double a = 25.64;
int b = 25;
a = a % 10;
b = b % 10;
System.out.println(a + " " + b); }
}
A. 5.640000000000001 5 B. 5.640000000000001 5.0 C. 5 5 D. 5 5.640000000000001

____8. What is the output of this program?


class increment {
public static void main(String args[])
{ int g = 3;
System.out.print(++g * 8); }
}
A. 25 B. 24 C. 32 D. 33
____9. What is the output of this program?
class Output {
public static void main(String args[])
{ int x , y;
x = 10;
x++;
--x;
y = x++;
System.out.println(x + " " + y); }
}
A. 11 11 B. 10 10 C. 11 10 D. 10 11

____10. Which of these statement is correct?


A. true and false are numeric values 1 and 0. B. true and false are numeric values 0 and 1.
C. true is any non zero value and false is 0. D. true and false are non numeric values.

____11. What is the range of data type short in Java?


A. -128 to 127 B. -32768 to 32767 C. -2147483648 to 2147483647 D. None of the mentioned

____12. What is the range of data type byte in Java?


A. -128 to 127 B. -32768 to 32767 C. -2147483648 to 2147483647 D. None of the mentioned

____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

____15. What is the numerical range of a char in Java?


A. -128 to 127 B. 0 to 256 C. 0 to 32767 D. 0 to 65535

____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

____17. Which of these values can a boolean variable contain?


A. True & False B. 0 & 1 C. Any integer value. D. Both a & b

____18. Which one is a valid declaration of a boolean?


A. boolean b1 = 1; B. boolean b2 = ‘false’; C. boolean b3 = false; D. boolean b4 = ‘true’

____19. What is the output of this program?


class mainclass {
public static void main(String args[])
{
char a = 'A';
a++;
System.out.print((int)a);
}
}
A. 66 B. 67 C. 65 D. 64

____20. What is the output of this program?


class mainclass {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
if (var1)
System.out.println(var1);
else
System.out.println(var2);}
}
A. 0 B. 1 C. true D. false

____21. Which is a valid keyword in java?


A. interface B. string C. Float D. unsigned

____22.The default value of a static integer variable of a class in Java is,


A. 0 B.1 C. Garbage value D. Null

____23. What will be printed as the output of the following program?


public class testincr
{
public static void main(String args[])
{
int i = 0;
i = i++ + i;
System.out.println(“I = ” +i);
}}
A. I = 0 B. I = 1 C. I = 2 D. I = 3

____24. Multiple inheritance means,


A. one class inheriting from more super classes B. more classes inheriting from one super class
C. more classes inheriting from more super classes D.None of the above

____25. Which statement is not true in java language?


A. A public member of a class can be accessed in all the packages.
B. A private member of a class cannot be accessed by the methods of the same class.
C. A private member of a class cannot be accessed from its derived class.
D. A protected member of a class can be accessed from its derived class.

____26. To prevent any method from overriding, we declare the method as,
A. static B. const C. final D. abstract

____27. Which one of the following is not true?


A. A class containing abstract methods is called an abstract class.
B. Abstract methods should be implemented in the derived class.
C. An abstract class cannot have non-abstract methods.
D. A class must be qualified as ‘abstract’ class, if it contains one abstract method.

____28. The fields in an interface are implicitly specified as,


A. static only B. protected C. private D. both static and final

____29. What is the output of the following program:


public class testmeth
{
static int i = 1;
public static void main(String args[])
{
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i)
{
i += 2;
}}
A. 1 , 3 B. 3 , 1 C. 1 , 1 D. 1 , 0

____30. Which of the following is not true?


A. An interface can extend another interface.
B. A class which is implementing an interface must implement all the methods of the interface.
C. An interface can implement another interface.
D. An interface is a solution for multiple inheritance in java.

____31. Which of the following is true?


A. A finally block is executed before the catch block but after the try block.
B. A finally block is executed, only after the catch block is executed.
C. A finally block is executed whether an exception is thrown or not.
D. A finally block is executed, only if an exception occurs.

____32. Among these expressions, which is(are) of type String?


A. “0” B. “ab” + “cd” C. ‘0’ D. Both A. and B. above

____33. Consider the following code fragment


Rectangle r1 = new Rectangle();
r1.setColor(Color.blue);
Rectangle r2 = r1;
r2.setColor(Color.red);
After the above piece of code is executed, what are the colors of r1 and
r2 (in this order)?
A. Color.blue Color.red B. Color.blue Color.blue C. Color.red Color.red D. Color.red Color.blue

____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;.

____38. Consider the following class definition:


public class MyClass
{
private int value;
public void setValue(int i){ / code / }
// Other methods…
}
The method setValue assigns the value of i to the instance field value. What could you write for the implementation of setValue?
A. value = i; B. this.value = i; C. value == i; D. Both A. and B. and above

____39. Which of the following is TRUE?


A. In java, an instance field declared public generates a compilation error.
B. int is the name of a class available in the package java.lang
C. Instance variable names may only contain letters and digits.
D. A class has always a constructor (possibly automatically supplied by the java compiler)

____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;.

____42. What is byte code in the context of Java?


A. The type of code generated by a Java compiler.
B. The type of code generated by a Java Virtual Machine.
C. It is another name for a Java source file.
D. It is the code written within the instance methods of a class.

____43. What is garbage collection in the context of Java?


A. The operating system periodically deletes all the java files available on the system.
B. Any package imported in a program and not used is automatically deleted.
C. When all references to an object are gone, the memory used by the object is automatically reclaimed.
D. The JVM checks the output of any Java program and deletes anything that doesn’t make sense.

____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()

____46. The correct order of the declarations in a Java program is,


A. Package declaration, import statement, class declaration
B. Import statement, package declaration, class declaration
C. Import statement, class declaration, package declaration
D. Class declaration, import statement, package declaration

____47. An overloaded method consists of,


A. The same method name with different types of parameters
B. The same method name with different number of parameters
C. The same method name and same number and type of parameters with different return type
D. Both A. and B. above
____48. A protected member can be accessed in,
A. a subclass of the same package B. a non-subclass of the same package
C. a non-subclass of different package D. a subclass of different package
Which is the false option?

____49. What is the output of the following code:


class eq
{
public static void main(String args[])
{
String s1 = “Hello”;
String s2 = new String(s1);
System.out.println(s1==s2);
}
}
A. true B. false C. 0 D. 1

____50. All exception types are subclasses of the built-in class


A. Exception B. RuntimeException C. Error D. Throwable

Prepared by:

KENT ERIC M. NARRA

Noted:

REBECCA K. SOTTO, Ph.D


Principal III

You might also like