Predict the output of the following Java code.
How many objects will be eligible for garbage collection in the given code?
Which of the following types of reference cannot be generic?
Which method of the httpd class is used to read data from the request stream?
Which methods are inherited from the java.lang.Object class?
public class abekus
{
public static void main(String[] args) {
int a = 10.0;
String temp = Integer.toString(a);
System.out.println(temp);
}
}
public class outputs
{
public static void main(String args[])
{
int a=10;
int b=20;
int c=30;
int sum=0;
sum= a++ + b++ + b*c++ + a*c++ ;
System.out.println(sum);
}
}
What is the output of the following Java code?
//Predict the output
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
StringBuilder str = new StringBuilder("superspider");
System.out.println(" "+ str.subSequence(0, 8));
}
}
What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (Exception ex)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
System.out.print("D");
}
public static void badMethod()
{
throw new Error(); /* Line 22 */
}
}
Predict the output of the following Java code:
class Abekus {
int a = 15;
int b = 22;
Abekus func(Abekus obj) {
Abekus obj3 = new Abekus();
obj3 = obj;
obj3.a = obj.a++ + ++obj.b;
obj.b = obj.b;
return obj3;
}
public static void main(String[] args) {
Abekus obj1 = new Abekus();
Abekus obj2 = obj1.func(obj1);
System.out.println("obj1.a = " + obj1.a + " obj1.b = " + obj1.b);
System.out.println("obj2.a = " + obj2.a + " obj2.b = " + obj2.b);
}
}