Question 1 of 25
Hints left: 3
Q1
Which of these exception is thrown in cases when the file specified for writing is not found?
Q2
Which of these class is used to read from a file?
Q3
What is a regular expression in Java?
Q4
Which of these values is returned by read() method is end of file (EOF) is encountered?
Q5
Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?
Q6
Which of these operators can be used to get run time information about an object?
Q7
Which of these methods is used to write() into a file?
Q8
What will be the output of the following Java program? class output { public static void main(String args[]) { String a="hello i love java"; System.out.println(indexof('i')+" "+indexof('o')+" "+lastIndexof('i')+" "+lastIndexof('o') )); } }
Q9
What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } }
Q10
What will be the output of the following Java program? import java.io.*; class filesinputoutput { public static void main(String args[]) { InputStream obj = new FileInputStream("inputoutput.java"); System.out.print(obj.available()); } } Note: inputoutput.java is stored in the disk.
Q11
Which of these exception is thrown by close() and read() methods?
Q12
Which of these functions is called to display the output of an applet?
Q13
Which of these class contains the methods used to write in a file?
Q14
What will be the output of the following Java program? class output { public static void main(String args[]) { char c[]={'a','1','b',' ','A','0']; for (int i = 0; i < 5; ++i) { if(Character.isDigit(c[i])) System.out.println(c[i]" is a digit"); if(Character.isWhitespace(c[i])) System.out.println(c[i]" is a Whitespace character"); if(Character.isUpperCase(c[i])) System.out.println(c[i]" is an Upper case Letter"); if(Character.isUpperCase(c[i])) System.out.println(c[i]" is a lower case Letter"); i = i + 3; } } }
Q15
What will be the output of the following Java program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdef"; int length = obj.length(); char c[] = new char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 0, 3); int i; try { while((i = input2.read()) != -1) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } }
Q16
Which of these methods can be used to output a string in an applet?
Q17
Which class is used to compile a regular expression in Java?
Q18
Which of these methods is a part of Abstract Window Toolkit (AWT) ?
Q19
What is the length of the application box made the following Java program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { Graphic g; g.drawString("A Simple Applet", 20, 20); }
Q20
What is the Message is displayed in the applet made by the following Java program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { public void paint(Graphics g) { g.drawString("A Simple Applet", 20, 20); } }
Q21
What will be the output of the following Java program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdefgh"; int length = obj.length(); char c[] = new char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 1, 4); int i; int j; try { while((i = input1.read()) == (j = input2.read())) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } }
Q22
Which of these methods are used to read in from file?
Q23
What will be the output of the following Java program? import java.io.*; public class filesinputoutput { public static void main(String[] args) { String obj = "abc"; byte b[] = obj.getBytes(); ByteArrayInputStream obj1 = new ByteArrayInputStream(b); for (int i = 0; i < 2; ++ i) { int c; while((c = obj1.read()) != -1) { if(i == 0) { System.out.print(Character.toUpperCase((char)c)); obj2.write(1); } } System.out.print(obj2); } } }
Q24
What will be the output of the following Java program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdefgh"; int length = obj.length(); char c[] = new char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 1, 4); int i; int j; try { while((i = input1.read()) == (j = input2.read())) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } }
Q25
What is the length of the application box made by the following Java program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { public void paint(Graphics g) { g.drawString("A Simple Applet", 20, 20); } }