Java is Compiler and Interpreter
Multitasking and Multiprogramming is NOT same.
Which of the following is used to compare whether two strings are equal or not.
Predict the output of the following Java code.
public class j{
public static void main(String args[]){
String str = "12acf23df4fg34";
System.out.println(str.replaceAll("\\D+", ""));
}
}
class test{
public static void main (String[] args) {
byte x = 4;
int i;
byte y;
i = x >> 2;
y = (byte) (x << 2);
System.out.print(i + " " + ~y);
}
}
public class testcase{
public static void main (String []args) {
try{}
catch(NullpointerException e){
System.out.println("Abekus");
}
catch(RuntimeException e){
System.out.println("creating question");
}
finally{
System.out.println("easy task");
}
}
}
Predict the output of the following Java code.
import java.util.List;
import java.util.ArrayList;
public class Abekus {
public static void main(String[] args) {
ArrayList<Integer> l = new ArrayList<Integer>(6);
l.add(25);
l.add(89);
l.add(14);
l.add(45);
l.remove(1);
l.add(34);
System.out.println(l.indexOf(45));
System.out.println(l.indexOf(2));
}
}
What will be the output of the program?
public class RTExcept
{
public static void throwit ()
{
System.out.print("throwit ");
throw new RuntimeException();
}
public static void main(String [] args)
{
try
{
System.out.print("hello ");
throwit();
}
catch (Exception re )
{
System.out.print("caught ");
}
finally
{
System.out.print("finally ");
}
System.out.println("after ");
}
}