Java Questions2
Java Questions2
Q2.Which component is responsible for converting bytecode into machine specific code?
JVM
JDK
JIT
JRE
1
Genesis Coding School An initiative by IT Professionals
Java
export
Q11.Which concept of Java is a way of converting real world objects in terms of class?
Polymorphism
Encapsulation
Abstraction
Inheritance
2
Genesis Coding School An initiative by IT Professionals
Java
Q18.Which concept of Java is achieved by combining methods and attribute into a class?
Encapsulation
Inheritance
Polymorphism
3
Genesis Coding School An initiative by IT Professionals
Java
Abstraction
4
Genesis Coding School An initiative by IT Professionals
Java
0
2
4
None of the mentioned
Q20.If data members are private, what can we do to access them from the class object?
Create public member functions to access those data members
Create private member functions to access those data members
Create protected member functions to access those data members
Private data members can never be accessed from outside the class
Q23.What would be the result if a class extends two interfaces and both have a method with same
name and signature? Lets assume that the class is not implementing that method.
Runtime error
5
Genesis Coding School An initiative by IT Professionals
Java
Q26.What is the process by which we can control what parts of a program can access the members
of a class?
Polymorphism
Abstraction
Encapsulation
Recursion
6
Genesis Coding School An initiative by IT Professionals
Java
Hierarchical inheritance
Multiple inheritance
7
Genesis Coding School An initiative by IT Professionals
Java
Q33.Which of this keyword can be used in a subclass to call the constructor of superclass?
super
this
extent
extends
8
Genesis Coding School An initiative by IT Professionals
Java
a) 9
b) 8
c) Compilation error
d) Runtime error
Q38.Which keyword is used by the method to refer to the object that invoked it?
9
Genesis Coding School An initiative by IT Professionals
Java
import
catch
abstract
this
a) 12
10
Genesis Coding School An initiative by IT Professionals
Java
b) 200
c) 400
d) 100
class test
{
int a;
int b;
void meth(int i , int j)
{
i *= 2;
j /= 2;
}
}
class Output
{
public static void main(String args[])
{
test obj = new test();
int a = 10;
int b = 20;
obj.meth(a , b);
System.out.println(a + " " + b); } }
11
Genesis Coding School An initiative by IT Professionals
Java
a) 10 20
b) 20 10
c) 20 40
d) 40 20
12
Genesis Coding School An initiative by IT Professionals
Java
{
public static void main(String args[])
{
box obj1 = new box();
box obj2 = new box();
obj1.height = 1;
obj1.length = 2;
obj1.width = 1;
obj2 = obj1;
System.out.println(obj2.height);
}
}
a) 1
b) 2
c) Runtime error
d) Garbage value
13
Genesis Coding School An initiative by IT Professionals
Java
class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
System.out.println(obj);
}
}
a) 0
b) 1
c) Runtime error
d) classname@hashcode in hexadecimal form
options:
b cannot contain value 100, limited by its range
* operator has converted b * 50 into int, which can not be converted to byte without casting
14
Genesis Coding School An initiative by IT Professionals
Java
15
Genesis Coding School An initiative by IT Professionals
Java
x = 5;
{
int y = 6;
System.out.print(x + " " + y);
}
System.out.println(x + " " + y);
}
}
a) 5 6 5 6
b) 5 6 5
c) Runtime error
d) Compilation error
a) 0
b) value stored in arr[0]
c) 00000
d) Hashcode in hexadecimal form
16
Genesis Coding School An initiative by IT Professionals
Java
variable
none of the metioned
17
Genesis Coding School An initiative by IT Professionals