What will be the output of the following Java 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);
}
}
a) 0
b) 1
c) 30
d) error
Answer: d
Explanation: Variable height is not defined.
Related Posts
People overcome natural language problems by _____________
The integrated circuit was invented by Jack Kilby of _____________
Research scientists all over the world are taking steps towards building computers with circuits patterned after the complex interconnections existing among the human brain’s nerve cells. What name is given to such type of computers?
Which type of actuator generates a good deal of power but tends to be messy?
In LISP, the function evaluates both and is _____________
Which of the following have people traditionally done better than computers?
A bidirectional feedback loop links computer modeling with _____________
Join The Discussion