81. What will be the output of the following Java 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);
}
}
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);
}
}
82. Which of the following is a method having same name as that of it's class?
83. What is the stored in the object obj in following lines of Java code?
box obj;
box obj;
84. Which concept of Java is a way of converting real world objects in terms of class?
85. Which component is responsible to optimize bytecode to machine code?
86. What will be the output of the following Java code?
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);
}
}
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);
}
}
87. Which of the following is a valid declaration of an object of class Box?
88. What is it called where child object gets killed if parent object is killed?
89. Which of these keywords is used to make a class?
90. #VALUE!
Read More Section(Constructors and Methods)
Each Section contains maximum 100 MCQs question on Constructors and Methods. To get more questions visit other sections.