What is the stored in the object obj in following lines of code?
box obj;
Memory address of allocated memory of object
NULL
Any arbitrary pointer
Garbage
SHOW ANSWERWhich of these keywords is used to make a class?
class
struct
int
none of the mentioned
SHOW ANSWERWhich of the following is a valid declaration of an object of class Box?
Box obj = new Box();
Box obj = new Box;
obj = new Box();
new Box obj;
SHOW ANSWERWhich of these operators is used to allocate memory for an object?
malloc
alloc
new
give
SHOW ANSWERWhich of these statement is incorrect?
Every class must contain a main() method
Applets do not require a main() method at all
There can be only one main() method in a program
main() method must be made public
SHOW ANSWERWhat is the output of this program?
class main_class
{
public static void main(String args[])
{
int x = 9;
if (x == 9)
{
int x = 8;
System.out.println(x);
}
}
}
9
8
Compilation error
Runtime error
SHOW ANSWERWhich of the following statements is correct?
Public method is accessible to all other classes in the hierarchy
Public method is accessible only to subclasses of its parent class
Public method can only be called by object of its class
Public method can be accessed by calling object of the public class
SHOW ANSWERWhat is the output of this program?
class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
obj.width = 10;
obj.height = 2;
obj.length = 10;
int y = obj.width * obj.height * obj.length;
System.out.print(y);
}
}
12
200
400
100
SHOW ANSWERWhat is the output of this program?
class box
{
int width;
int height;
int length;
}
class mainclass
{
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);
}
}
1
2
Runtime error
Garbage value
SHOW ANSWERWhat is the output of this program?
class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
System.out.println(obj);
}
}
0
1
Runtime error
classname@hashcode in hexadecimal form
SHOW ANSWERWhat is the process of defining more than one method in a class differentiated by method signature?
Method overriding
Method overloading
Method doubling
None of the mentioned
SHOW ANSWERWhich of the following is a method having same name as that of it’s class?
finalize
delete
class
constructor
SHOW ANSWERWhich method can be defined only once in a program?
main method
finalize method
static method
private method
SHOW ANSWER