Discussion Forum : Introduction To Methods And Streams
Question -


What is the output of this program?


class area {
int width;
int length;
int volume;
area() {
width = 5;
length = 6;
}
void volume() {
volume = width * height * length;
}
}
class cons_method {
public static void main(String args[]) {
area obj = new area();
obj.volume();
System.out.println(obj.volume);
}
}
Options:
A .  0
B .  1
C .  25
D .  30
Answer: Option D

 None.
output:
$ javac cons_method.java
$ java cons_method
30



Was this answer helpful ?
Next Question
Submit Your Solution hear:

Your email address will not be published. Required fields are marked *