Q1, class floattest {
public static void main(
String[] args) {
final String a = "A";//1
final String b = "B";//2
final String c = a+b;
final String d = a+b;
System.out.print((c==c) + ",");
System.out.print(((a+b)==(a+b)) + ",");
System.out.print(c==d);
}
}
try out taking final in 1 and 2...why this behaviour?
Q2,
Why cant a local variable in
java be static?...while in C++ static
variables inside a method is allowed
Q3,
public class Question20 {
public static void main(String[] args) {
Question20Sub myref = new Question20Sub();
try{
myref.test();
}catch(Exception e){}
}
void
test() throws Exception{
System.out.println("In Question20");
throw new Exception();
}
}
class Question20Sub extends Question20 {
void test() {
System.out.println("In Question20Sub");
}
}
***********************************************************
this works...while the next doesn't.... why?
***********************************************************
import java.io.*;
public class Question05 {
public static void main(String[] args) {
Question05Sub myref = new Question05Sub();
try{
myref.test();
}catch(IOException ioe){}
}
void test() throws IOException{
System.out.println("In Question05");
throw new IOException();
}
}
class Question05Sub extends Question05 {
void test() {
System.out.println("In Question05Sub");
}
}