a) Private constructor ensures only one instance of a class exist at any point of time b) Private ...
View Question
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);
}
}
What will be the output of the following Java program? class area ...
View Question
In the following Java code, which call to sum() method is appropriate?
class Output
{
public static int sum(int …x)
{
return;
}
static void main(String args[])
{
sum(10);
sum(10,20);
sum(10,20,30);
sum(10,20,30,40);
}
}
In the following Java code, which call to sum() method is appropriate? class Output { ...
View Question
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);
}
}
What will be the output of the following Java program? class box ...
View Question
What will be the output of the following Java program?
class equality
{
int x;
int y;
boolean isequal()
{
return(x == y);
}
}
class Output
{
public static void main(String args[])
{
equality obj = new equality();
obj.x = 5;
obj.y = 5;
System.out.println(obj.isequal());
}
}
What will be the output of the following Java program? class equality ...
View Question
What will be the output of the following Java program?
class box
{
int width;
int height;
int length;
int volume;
void volume(int height, int length, int width)
{
volume = width*height*length;
}
}
class Prameterized_method
{
public static void main(String args[])
{
box obj = new box();
obj.height = 1;
obj.length = 5;
obj.width = 5;
obj.volume(3,2,1);
System.out.println(obj.volume);
}
}
What will be the output of the following Java program? class box ...
View QuestionWhich of this statement is incorrect?
a) All object of a class are allotted memory for the all the variables defined in the ...
View QuestionWhich method can be defined only once in a program?
a) main method b) finalize method c) static method d) private method Answer: a Explanation: main() method can be defined only once in a ...
View QuestionWhich of the following is a method having same name as that of it’s class?
a) finalize b) delete c) class d) constructor Answer: d Explanation: A constructor is a method that initializes an ...
View QuestionWhat is the process of defining more than one method in a class differentiated by method signature?
a) Function overriding b) Function overloading c) Function doubling d) None of the mentioned Answer: b Explanation: Function overloading ...
View Question