Quiz - JAVA & OOP Quiz
Quiz - JAVA & OOP Quiz
Quiz - JAVA & OOP Quiz
Date
2. Which component is used to compile, debug and execute the java programs?
A JRE
B JIT
C JDK
D JVM
B Use of pointers
C Po table
C Identifiers
D Keyword
A .js
B .txt
C .class
D .java
6. What will be the output of the following Java code?
class increment {
public static void main(St ing args[])
{
int g = 3;
System.out.p int(++g * 8 ;
}
}
A 32
B 33
C 24
D 25
class output {
public static void main(St ing args[])
{
double a, b,c;
a = 3.0/0;
b = 0/4.0;
c=0/0.0;
System.out.p intln(a);
System.out.p intln(b);
System.out.p intln(c);
}
}
A NaN
B Infinity
C 0.0
B Compilation
C Inhe itance
D Encapsulation
9. What is not the use of “this” keyword in Java?
A Passing itself to the method of the same class
B Refe ing to the instance va iable when a local va iable has the same name
class va iable_scope
{
public static void main(St ing args[])
{
int x;
x = 5;
{
int y = 6;
System.out.p int(x + " " + y);
}
System.out.p intln(x + " " + y);
}
}
A Compilation e ror
B Runtime e ror
C 5656
D 565
byte b = 50;
b = b * 50;
D * operator has conve ted b * 50 into int, which can not be conve ted to byte without casting
12. Which of the following is a type of polymorphism in Java Programming?
A Multiple polymorphism
C Multilevel polymorphism
class leftshift_operator
{
public static void main(St ing args[])
{
byte x = 64;
int i;
byte y;
i = x << 2;
y = (byte) (x << 2
System.out.p int(i + " " + y);
}
}
A 0 256
B 0 64
C 256 0
D 64 0
14. What will be the output of the following Java code?
class box
{
int width;
int height;
int length;
}
class main
{
public static void main(St ing args[])
{
box obj = new box();
obj.width = 10;
obj.height = 2;
obj.length = 10;
int y = obj.width * obj.height * obj.length;
System.out.p int(y);
}
}
A 100
B 400
C 200
D 12
class Output
{
public static void main(St ing args[])
{
int a r[] = 1, 2, 3, 4, 5 ;
for ( int i = 0; i < a r.length - 2; ++i)
System.out.p intln(a r[i] + " ");
}
}
A 12345
B 1234
C 12
D 123
17. What will be the output of the following Java code snippet?
class abc
{
public static void main(St ing args[])
{
if(args.length>0
System.out.p intln(args.length);
}
}
A The snippet compiles and uns but does not p int anything
B .js
C .java
D .class
19. Which exception is thrown when java is out of memo y?
A Memo yE ror
B OutOfMemo yE ror
C Memo yOutOfBoundsException
D Memo yFullException
class St ing_demo
{
public static void main(St ing args[])
{
char chars[] = {'a', 'b', 'c'};
St ing s = new St ing(chars);
System.out.p intln(s);
}
}
A abc
B a
C b
D c
B continue
C for()
class recursion
{
int func (int n)
{
int result;
if (n == 1
retu n 1;
result = func (n - 1 ;
retu n result;
}
}
class Output
{
public static void main(St ing args[])
{
recursion obj = new recursion() ;
System.out.p int(obj.func(5 ;
}
}
A 1
B 120
C 0
class output
{
public static void main(St ing args[])
{
St ing c = "Hello i love java";
boolean var;
var = c.sta tsWith("hello");
System.out.p intln(var);
}
}
A 0
B t ue
C 1
D false
24. What will be the output of the following Java program?
class output
{
public static void main(St ing args[])
{
St ingBuffer s1 = new St ingBuffer("Quiz");
St ingBuffer s2 = s1.reverse();
System.out.p intln(s2 ;
}
}
A QuizziuQ
B ziuQQuiz
C Quiz
D ziuQ
class Output
{
public static void main(St ing args[])
{
Integer i = new Integer(257 ;
byte x = i.byteValue();
System.out.p int(x);
}
}
A 257
B 256
C 1
D 0
26. What will be the output of the following Java program?
class Output
{
public static void main(St ing args[])
{
double x = 2.0;
double y = 3.0;
double z = Math.pow( x, y );
System.out.p int(z);
}
}
A 9.0
B 8.0
C 4.0
D 2.0
B Abstract Class
C Object Class
D St ing
class Output
{
public static void main(St ing args[])
{
double x = 3.14;
int y = (int) Math.ceil(x);
System.out.p int(y);
}
}
A 3
B 0
C 4
D 3.0
29. What will be the output of the following Java code snippet?
impo t java.util.*;
class A raylists
{
public static void main(St ing args[])
{
A rayLists obj = new A rayLists();
obj.add("A");
obj.add("B");
obj.add("C");
obj.add(1, "D");
System.out.p intln(obj);
}
}
A A, D, C
B A, B, C
C A, B, C, D
D A, D, B, C
impo t java.util.*;
class Collection_iterators
{
public static void main(St ing args[])
{
LinkedList list = new LinkedList();
list.add(new Integer(2 ;
list.add(new Integer(8 ;
list.add(new Integer(5 ;
list.add(new Integer(1 ;
Iterator i = list.iterator();
Collections.reverse(list);
Collections.so t(list);
while(i.hasNext())
System.out.p int(i.next() + " ");
}
}
A 1258
B 2185
C 1582
D 2851