Preview

Java Test

Satisfactory Essays
Open Document
Open Document
469 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java Test
DUCAT Java Test (Batch 10:30 to 12:30)
Duration 1 Hr

Q1. class B { public static void main (String[] args) { for (int i = 0; i < 4; i++) { switch (i) { case 0: System.out.print("A"); case 1: System.out.print("B"); case 2: System.out.print("C"); }}}} What is the result of attempting to compile and run the program?
a) Print ABC
b) Print ABCC
c) Print CBA
d) Print ABCBCC
e) Runtime error
f) Compile time error
Answer d)

Q2. Which access modifier is used with class name
a) Class can be public and protected
b) Class can be public and default
c) Class can be private and default
d) Class can be of public, protected , private and default.
Answer b)

Q3. “ X extends Y “ is correct if and only if X is a class and Y is an interface.
a) “X extends Y “ is correct if and only if X is an interface and Y is a class.
b) “X extends Y “ is correct if X and Y are either both classes or both interfaces.
c) “ X extends Y “ is correct if and only if X is a class and Y is an interface.
d) None of these
Answer b) Q4. What will be the output? if(1) System.out.println(“TRUE”); else System.out.println(“FALSE”);

a) Print True
b) Print False
c) Compile Time Error
d) Run Time Error
Answer c)

Q5. What will be the output ? class A { protected void show() { System.out.println(“Inside A Class show “); } } class B extends A { void show() { System.out.println(“Inside B Class Show “); } } class Test { public static void main(String args[]) { B obj=new B(); obj.show(); } }

a) Inside B class show
b) Inside A class show
c) Compile Time Error
d) Inside B Class Show, Inside A Class Show
Answer c)

Q6. What is the value of 111%13
a) 7
b) 11
c) 5
d) 3
Answer a)

Q7.Which of the following are compiling without warning or error? (Choose all that apply)
a) float f=1.3;
b) char c=”A”;
c) byte b=257;
d) boolean b=null;
e) int i=10;
Answer e)

Q8. What will happen when

You May Also Find These Documents Helpful