What will be the output of the following Java code?
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);
}
}Select an option to see the answer and solution.
What will be the output of the following Java program?
class main_class
{
public static void main(String args[])
{
int x = 9;
if (x == 9)
{
int x = 8;
System.out.println(x);
}
}
}A. 9
B. 8
C. Compilation error
D. Runtime error
Select an option to see the answer and solution.
What is -Xms and -Xmx while starting jvm?
A. Initial; Maximum memory
B. Maximum; Initial memory
C. Maximum memory
D. Initial memory
Select an option to see the answer and solution.
What will be the output of the following Java program?
class recursion
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.fact(6));
}
}Select an option to see the answer and solution.
What will be the output of the following Java program?
class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
obj.width = 10;
obj.height = 2;
obj.length = 10;
int y = obj.width * obj.height * obj.length;
System.out.print(y);
}
}Select an option to see the answer and solution.
What 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
Select an option to see the answer and solution.
Which of the following statements is correct?
A. Public method is accessible to all other classes in the hierarchy
B. Public method is accessible only to subclasses of its parent class
C. Public method can only be called by object of its class
D. Public method can be accessed by calling object of the public class
Select an option to see the answer and solution.
Which of this statement is incorrect?
A. All object of a class are allotted memory for the all the variables defined in the class
B. If a function is defined public it can be accessed by object of other class by inheritation
C. main() method must be made public
D. All object of a class are allotted memory for the methods defined in the class
Select an option to see the answer and solution.
Which concept of Java is achieved by combining methods and attribute into a class?
A. Encapsulation
B. Inheritance
C. Polymorphism
D. Abstraction
Select an option to see the answer and solution.
What will be the output of the following Java program?
class recursion
{
int fact(int n)
{
int result;
if (n == 1)
return 1;
result = fact(n - 1) * n;
return result;
}
}
class Output
{
public static void main(String args[])
{
recursion obj = new recursion() ;
System.out.print(obj.fact(1));
}
}A. 1
B. 30
C. 120
D. Runtime Error
Select an option to see the answer and solution.
How to get prints of shared object memory maps or heap memory maps for a given process?
A. jmap
B. memorymap
C. memorypath
D. jvmmap
Select an option to see the answer and solution.
Which of these is not a correct statement?
A. A recursive method must have a base case
B. Recursion always uses stack
C. Recursive methods are faster that programmers written loop to call the function repeatedly using a stack
D. Recursion is managed by Java Runtime environment
Select an option to see the answer and solution.
Which of these data types is used by operating system to manage the Recursion in Java?
A. Array
B. Stack
C. Queue
D. Tree
Select an option to see the answer and solution.
Which of the following is a method having same name as that of its class?
A. finalize
B. delete
C. class
D. constructor
Select an option to see the answer and solution.
Which method can be defined only once in a program?
A. main method
B. finalize method
C. static method
D. private method
Select an option to see the answer and solution.
Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?
A. delete
B. free
C. new
D. none of the mentioned
Select an option to see the answer and solution.
What is the extension of java code files?
A. .class
B. .java
C. .txt
D. .js
Select an option to see the answer and solution.
When Overloading does not occur?
A. More than one method with same name but different method signature and different number or type of parameters
B. More than one method with same name, same signature but different number of signature
C. More than one method with same name, same signature, same number of parameters but different type
D. More than one method with same name, same number of parameters and type but different signature
Select an option to see the answer and solution.
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);
}
}Select an option to see the answer and solution.
What happens to the thread when garbage collection kicks off?
A. The thread continues its operation
B. Garbage collection cannot happen until the thread is running
C. The thread is paused while garbage collection runs
D. The thread and garbage collection do not interfere with each other
Select an option to see the answer and solution.