
Practice Inner Classes –
What will be the output of the program?
public class HorseTest {
public static void main (String [] args) {
class Horse {
public String name; /* Line 7 */
public Horse(String s) {
name = s;
}
} /* class Horse ends */
Object obj = new Horse("Zippo"); /* Line 13 */
Horse h = (Horse) obj; /* Line 14 */
System.out.println(h.name);
}
} /* class HorseTest ends */
Which of the following is true in Java?
Which of the following is true in Java?
Practice Language Fundamentals –
Which of the following is true in Java?
Which of the following is true in Java?
Which of the following is true in Java?
Practice Language Fundamentals –
Which of the following is true in Java?
import java.io.*;
public class
import java.io.*;
public class

Practice Exceptions –
import java.io.*;
public class MyProgram {
public static void main(String args[]) {
FileOutputStream out = null;
try {
out = new FileOutputStream("test.txt");
out.write(122);
}
catch(IOException io) {
System.out.println("IO Error.");
}
finally {
out.close();
}
}
}
and given that all methods of class FileOutputStream, including close(), throw an IOException, which of these is true?

Practice Exceptions –
What will be the output of the program?
class Exc0 extends Exception { }
class Exc1 extends Exc0 { } /* Line 2 */
public class Test {
public static void main(String args[]) {
try {
throw new Exc1(); /* Line 9 */
}
catch (Exc0 e0) /* Line 11 */{
System.out.println("Ex0 caught");
}
catch (Exception e) {
System.out.println("exception caught");
}
}
}