Syvum Home Page

Home > Quiz Games > Java Programming > Print Preview

Java Programming : java.awt and java.io : Multiple Choice

Formats Info Page Worksheet / Test Paper Quiz Review

Hide all answers   View all answers   Print   Try the Quiz

Learn about java.awt and java.io packages.


1. When we invoke repaint() for a java.awt.Component object, the AWT invokes the method:
• draw()
• update()
• show()
• paint()
Answer: update()

2. What does the following line of code do?
Textfield text = new Textfield(10);
• Creates text object that can hold 10 rows of text.
• Creates the object text and initializes it with the value 10.
• Creates text object that can hold 10 columns of text.
• The code is illegal.
Answer: Creates text object that can hold 10 columns of text.

3. Which of the following applet tags is legal to embed an applet class named Test into a Web page?
• < applet
class = Test width = 200 height = 100>

• < applet>
code = Test.class width = 200 height = 100>

• < applet
code = Test.class width = 200 height = 100>

• < applet
code = Test.class width = 200 height = 100

• < applet
param = Test.class width = 200 height = 100>

Answer: < applet
code = Test.class width = 200 height = 100>


4. Which of the following methods can be used to draw the outline of a square within a java.awt.Component object?
(A) fillRect()
(B) drawLine()
(C) drawRect()
(D) drawString()
(E) drawPolygon()
• (B), (C) & (E)
• (A), (B), (C) & (E)
• (A), (B) & (C)
• (C), (D) & (E)
• (B) & (C)
Answer: (B), (C) & (E)

5. Which of the following methods can be used to change the size of a java.awt.Component object?
(A) dimension()
(B) setSize()
(C) area()
(D) size()
(E) resize()
• (A), (B), (C) & (E)
• (A), (B) & (E)
• (B) & (E)
• (B), (D) & (E)
• (D) & (E)
Answer: (B) & (E)

6. Which of the following methods can be used to remove a java.awt.Component object from the display?
• delete()
• hide()
• remove()
• disappear()
• move()
Answer: hide()

7. The setBackground() method is part of the following class in java.awt package:
• Graphics
• Component
• Applet
• Container
• Object
Answer: Component

8. Which of the following strings can be used as mode strings for creating a RandomAccessFile object?
(A) "r"
(B) "w"
(C) "rw"
(D) "wr"
(E) "0"
• (A), (B), (C) & (E)
• (A) & (C)
• (A), (B) & (C)
• (B), (D) & (E)
• (C) & (D)
Answer: (A) & (C)

9. DataInput is
• an abstract class defined in java.io.
• an interface that defines methods to read primitive data types.
• a class we can use to read primitive data types.
• an interface that defines methods to open files.
Answer: an interface that defines methods to read primitive data types.

10. Which of the following statements are true?
(A) Unicode characters are all 16 bits.
(B) UTF characters are all 24 bits.
(C) Reader class has methods that can read integers and floats.
(D) File class may be used to rename a file.
(E) DataOutputStream objects are used to write primitive data to a file.
• (A), (C), (D) & (E)
• (A), (B) & (D)
• (B), (D) & (E)
• (A) & (D)
• (A), (D) & (E)
Answer: (A), (D) & (E)

11. Which are the valid ways to create DataInputStream streams?
• new DataInputStream();
• new DataInputStream("in.dat", "r");
• new DataInputStream(new FileInputStream("in.dat");
• new DataInputStream("in.dat")
• new DataInputStream(new File("in.dat"));
Answer: new DataInputStream(new FileInputStream("in.dat");

12. Which exception is thrown by the read() method of InputStream class?
• Exception
• IOException
• FileNotFoundException
• ReadException
• None of these
Answer: IOException

13. If you want to assign a value of 99 to the variable year, then which of the following lines can be used within an tag?
• number = getParameter(99)
• < number = 99 >
• < param name = number value = 99 >
• < param = radius value = 99 >
• < param number = 99 >
Answer: < param name = number value = 99 >

14. Given file is a File object, which of the following are legal statements to create a new file?
(A) file.create();
(B) FileOutputStream fos = new FileOutputStream(file);
(C) FileWrter out = new FileWriter(file);
(D) FileInputStream fis = new FileInputStream(file);
(E) RandomAccessFile raf = new RandomAccessFile(file);
• (A), (B), (D) & (E)
• (B), (C) & (D)
• (B), (D) & (E)
• (B) & (C)
• (B), (C) & (E)
Answer: (B), (C) & (E)

  Try the Quiz :     Java Programming : java.awt and java.io : Multiple Choice


Contact Info © 1999-2024 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright
Previous
-
Next
-