What is the output of this program?
class box
{
int width;
int height;
int length;
int volume;
void volume()
{
volume = width*height*length;
}
}
class Output
{
public static void main(String args[])
{
box obj = new box();
obj.height = 1;
obj.length = 5;
obj.width = 5;
obj.volume();
System.out.println(obj.volume);
}
}
0
1
25
26
SHOW ANSWERWhat is the output of this program?
class area
{
int width;
int length;
int volume;
area()
{
width=5;
length=6;
}
void volume()
{
volume = width*length*height;
}
}
class cons_method
{
public static void main(String args[])
{
area obj = new area();
obj.volume();
System.out.println(obj.volume);
}
}
0
1
30
error
SHOW ANSWERWhat is the return type of Constructors?
int
float
void
none of the mentioned
SHOW ANSWERWhich keyword is used by the method to refer to the object that invoked it?
import
this
abstract
catch
SHOW ANSWERWhich of the following is a method having same name as that of its class?
finalize
delete
constructor
class
SHOW ANSWERWhich operator is used by Java run time implementations to free the memory of an object when it is no longer needed?
delete
free
new
none of the mentioned
SHOW ANSWERWhat is the output of this program?
class box
{
int width;
int height;
int length;
int volume;
box()
{
width = 5;
height = 5;
length = 6;
}
void volume()
{
volume = width*height*length;
}
}
class constructor_output
{
public static void main(String args[])
{
box obj = new box();
obj.volume();
System.out.println(obj.volume);
}
}
100
150
200
250
SHOW ANSWERWhat is the output of this program?
class area
{
int width;
int length;
int area;
void area(int width, int length)
{
this.width = width;
this.length = length;
}
}
class Output
{
public static void main(String args[])
{
area obj = new area();
obj.area(5 , 6);
System.out.println(obj.length + " " + obj.width);
}
}
0 0
5 6
6 5
5 5
SHOW ANSWERWhat is true about constructor?
It can contain return type
It can take any number of parameters
It can have any non access modifiers
Constructor cannot throw an exception
SHOW ANSWERWhat would be behaviour if the constructor has a return type?
Compilation error
Runtime error
Compilation and runs successfully
Only String return type is allowed
SHOW ANSWERWhich of the following has the highest memory requirement?
Heap
Stack
JVM
Class
SHOW ANSWERWhat is the process of defining two or more methods within same class that have same name but different parameters declaration?
method overloading
method overriding
method hiding
none of the mentioned
SHOW ANSWERWhich of these can be overloaded?
Methods
Constructors
All of the mentioned
None of the mentioned
SHOW ANSWER