How many ways to create an object
Predict the output of the following Java code.
public class abekus {
public static void main(String[] args){
String s = "abekus";
int x = 0;
do {
System.out.print(s.charAt(x));
x++ ;
} while (x < 2);
}
}
Which of the following Java statements will not raise an error?
How many times 'abekus' is printed?
public class abekus
{
public static void main(String[] args) {
while(true){
System.out.println("abekus");
}
}
}
class jj
{
public static void main(String args[])
{
StringBuffer sb = new StringBuffer("Abekus");
sb.replace(1,2,"Hello");
System.out.println(sb);
}
}
Statement 1- Interface allows us to call generic methods as a normal method
Statement 2-Type Interface allows us to call generic methods as a normal method
Statement 3- Inner class allows us to call generic methods as a normal method
Predict the output of the following Java code:
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Abekus");
s1.insert(3 , "Abekus");
System.out.println(s1);
}
}
Predict the output of the following Java code:
public class Abekus {
static Abekus A;
static int c = 0;
public static void main(String[] args) throws InterruptedException
{
Abekus A1 = new Abekus();
A1 = null;
System.gc();
Thread.sleep(500);
A = null;
System.gc();
Thread.sleep(500);
System.out.println("finalize() calls : " + c);
}
protected void finalize() {
c++;
A = this;
}
}
import java.util.*;
class output
{
public static void main(String args[])
{
LinkedList set = new LinkedList();
set.add(new Integer(3));
set.add(new Integer(8));
set.add(new Integer(5));
set.add(new Integer(1));
set.addFirst(new Integer(2));
set.addLast(new Integer(2));
Iterator i = set.iterator();
Collections.reverse(set);
Collections.shuffle(set);
i.next();
i.remove();
while(i.hasNext())
System.out.print(i.next() + " ");
}
}