Professional Documents
Culture Documents
A) FileNotExist
B) FileNotExistException
C) FileNotFound
D) FileNotFoundException
A) close
B) print
C) exist
D) rename
3. After the following program is finished, how many bytes are written to the
file new.data.
import java.io.*;
new FileOutputStream("new.dat"));
output.writeChars("ABCD");
output.close();
}
}
A) 2
B) 8
C) 16
D) 4
4. ________ class contains the method for checking whether a file exists.
A) File
B) PrintWriter
C) Scanner
D) System
StringBuffer s2 = s1.reverse();
System.out.println(s2);
A) Hello
B) olleH
C) HelloolleH
D) olleHHello
6. Identify the correct method of ArrayList class that is used to obtain present
size of an object.
A) size()
B) length()
C) index()
D) capacity()
A) Class.forName(sun.jdbc.odbc.JdbcOdbcDriver)
B) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
C) Class.loadClass(sun.jdbc.odbc.JdbcOdbcDriver)
D) Class.loadClass("sun.jdbc.odbc.JdbcOdbcDriver")
A) 7
B) 16
C) 9
D) 32/23
A) TextBox
B) CheckBox
C) TextComponent
D) Choice
10. AppletViewer tool is available in which of the folder of JDK
A) bin
B) lib
C) source
D) class
A) new FileOutputStream("out.dat")
12. Interpret the method that can be used to read a whole line from a file.
A) next
B) nextLine
C) nextInt
D) nextDouble
13. Identify the correct statement that creates an instance of File on Window for
the file c:\temp.txt.
A) new File("c:\temp.txt")
B) new File("c:\\temp.txt")
C) new File("c:/temp.txt")
D) new File("c://temp.txt")
A) [New York]
A) "peter".compareToIgnoreCase("Peter")
B) "peter".compareToIgnoreCase("peter")
C) "peter".equalsIgnoreCase("Peter")
D) "peter".equalsignoreCase("peter")
16. Assume s is " abc ", the method __________ returns a new string "abc".
A) s.trim(s)
B) trim(s)
C) String.trim(s)
D) s.trim()
A) JavaAAAneat
B) JavaAAA neat
D) Java AAAneat
18. The _______ method in the applet is invoked when the user leaves the page
that contains the applet.
A) init
B) start
C) stop
D) destroy
19. To use an applet in the HTML document, you use __________ in the
<applet> tag.
B) .class bytecode
D) .html file
A) .java
B) .obj
C) .class
D) .exe
3. The JVM stores the array in an area of memory, called _______, which is
used for dynamic memory allocation where blocks of memory are allocated and
freed in an arbitrary order.
A) dynamic memory
B) memory block
C) heap
D) stack
System.out.println(1 / 0); } }
A) ArithmeticException
B) ArrayIndexOutOfBoundsException
C) StringIndexOutOfBoundsException
D) ClassCastException
6. Infer how many times will the following code print "Welcome to Java".
int count = 0;
System.out.println("Welcome to Java");
A) 8
B) 9
C) 10
D) 11
A) Composition
B) Aggregation
C) Inheritance
D) Association
A) 7
B) 16
C) 9
D) 32/23
10. ________ class contains the method for checking whether a file exists.
A) File
B) PrintWriter
C) Scanner
D) System
A) new FileOutputStream("out.dat")
12. Identify the correct statement that creates an instance of File on Window for
the file c:\temp.txt.
A) new File("c:\temp.txt")
B) new File("c:\\temp.txt")
C) new File("c:/temp.txt")
D) new File("c://temp.txt")
13. Identify the exception which occurs when creating a DataInputStream for a
nonexistent file.
A) FileNotExist
B) FileNotExistException
C) FileNotFound
D) FileNotFoundException
14. Assume
A) calendar.get(Calendar.MONTH)
B) calendar.get(Calendar.MONTH_OF_YEAR)
C) calendar.get(Calendar.WEEK_OF_MONTH)
D) calendar.get(Calendar.WEEK_OF_YEAR)
15. Suppose ArrayList x contains two strings [Beijing, Singapore]. Which of the
following methods will cause the list to become [Beijing, Chicago, Singapore]?
A) x.add("Chicago")
B) x.add(0, "Chicago")
C) x.add(1, "Chicago")
D) x.add(2, "Chicago")
16. Assume s is " abc ", the method __________ returns a new string "abc".
A) s.trim(s)
B) trim(s)
C) String.trim(s)
D) s.trim()
A) TextBox
B) CheckBox
C) TextComponent
D) Choice
A) bin
B) lib
C) source
D) class
20. Among the following statements,which one loads the JDBC-ODBC driver?
A) Class.forName(sun.jdbc.odbc.JdbcOdbcDriver)
B) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")
C) Class.loadClass(sun.jdbc.odbc.JdbcOdbcDriver)
D) Class.loadClass("sun.jdbc.odbc.JdbcOdbcDriver")
In order to compile this program, the source code should be stored in a file named
A) Test.class
B) Testfile.java
C) Testfile.class
D) Test.java
2. After the following program is finished, how many bytes are written to the
file new.data.
import java.io.*;
new FileOutputStream("new.dat"));
output.writeChars("ABCD");
output.close();
}
}
A) 2
B) 8
C) 16
D) 4
3. We can use the ________ method to force one thread to wait for another
thread to finish.
A) sleep(long milliseconds)
B) yield()
C) suspend()
D) join()
A) sin.nextInt();
B) sin.nextInteger();
C) sin.int();
D) sin.integer();
A) Java bytecode
B) machine code
C) assembly code
A) class A { }
C) final class A { }
8. Which method can be used to create an output object for file temp.txt?
A) new PrintWriter("temp.txt")
B) new PrintWriter(temp.txt)
D) new PrintWriter(File("temp.txt"))
i++;
A) 123456789
B) 1 2 3 4 5 6 7 8 9 10
C) 13579
D) 2 4 6 8 10
10. Interpret the method that can be used to read a whole line from a file.
A) next
B) nextLine
C) nextInt
D) nextDouble
A) 0
B) 3
C) 4
D) 5
12. _______ class contains the method for checking whether a file exists.
A) File
B) PrintWriter
C) Scanner
D) System
A) [New York]
B) [New York, Atlanta]
14. The _______ method in the applet is invoked when the user leaves the page
that contains the applet.
A) init
B) start
C) stop
D) destroy
15. Suppose an ArrayList list contains {"red", "green", "red", "green"}. What is
list after the following code?
list.remove("red");
C) {"green", "green"}
StringBuffer s2 = s1.reverse();
System.out.println(s2);
}
A) Hello
B) olleH
C) HelloolleH
D) olleHHello
A) FlowLayout
B) GridLayout
C) BorderLayout
D) BoxLayout
A) JavaAAAneat
B) JavaAAA neat
D) Java AAAneat
A) MouseListener
B) ActionListener
C) FocusListener
D) WindowListener
20. To use an applet in the HTML document, you use __________ in the
<applet> tag.
B) .class bytecode
D) .html file