MCQ Bank
Which of the following methods is invoked by the AWT package to support paint and repaint operations?
- A) repaint( )
- B) redraw( )
- C) paint( )
- D) draw( )
Which of the following is the correct syntax to make a PersonInfo class into a Serializable class?
- A) public class PersonInfo extends Serializable { /* class body */}
- B) public class PersonInfo implements Serializable { /* class body */}
- C) public class PersonInfo includes Serializable { /* class body */}
- D) public class PersonInfo imports Serializable { /* class body */}
What is the purpose of the transient keyword in Java serialization?
- A) It indicates that a class cannot be serialized.
- B) It indicates that an object cannot be serialized.
- C) It indicates that a variable should not be serialized.
- D) It indicates that a method cannot be serialized.
What happens when you call the repaint() method on a Swing component?
- A) The component's size is adjusted to fit its contents.
- B) The component is moved to a different location in the GUI.
- C) The component is immediately removed from the GUI.
- D) The component is marked for repainting and will be redrawn by the system.
Which of the following methods takes the place of constructor in an Applet?
- A) init()
- B) run()
- C) start()
- D) main()
Assume that we do not want to serialize phoneNum attribute of PersonInfo class, this can be done by:
- A) client String phoneNum;
- B) serializable String phoneNum;
- C) server String phoneNum;
- D) transient String phoneNum;
An applet is basically a/an _____________ that allows interaction with a Java program.
- A) Frame
- B) Label
- C) Window
- D) Panel
Socket is a ___________ commnunication channel between hosts.
- A) uni-directional
- B) tri-directional
- C) multi-directional
- D) bi-directional
Which of the following methods of Graphics object is used to draw rectangle?
- A) DrawRect(10,10,20,20);
- B) DrawReactangle(10,10,20,20);
- C) drawReactangle(10,10,20,20);
- D) drawRect(10,10,20,20);
Which method is called first when an applet is loaded?
- A) start()
- B) stop()
- C) init()
- D) destroy()
Which of the following statements is true regarding paintChildren() method?
- A) It tells any components contained by this component to paint themselves.
- B) It first paints the background and then performs custom painting.
- C) It first performs custom painting and then paints the background.
- D) It tells the component to paint its border.
Which of the given will clear all the previous painting?
- A) super.repaint()
- B) super.redraw()
- C) super.paintComponent()
- D) super.paint()
Which keyword is used in Java to mark fields that should not be serialized?
- A) static
- B) transient
- C) volatile
- D) final
How many ports are available for TCP socket?
- A) 128k
- B) 128
- C) 64k
- D) 64
HTTP works on port _________.
- A) 80
- B) 84
- C) 21
- D) 23
Timer class constructor requires time in _______________.
- A) milli seconds
- B) nano seconds
- C) micro seconds
- D) seconds
An applet can be defined as:
- A) A small program written in JSF and included in an HTML page
- B) A small program written in Java and included in an HTML page
- C) A small program written in JSP and included in an HTML page
- D) A small program written in Servlet and included in an HTML page
Which method of ServerSocket class is used to accept incoming client connections in Java?
- A) bind()
- B) accept()
- C) connect()
- D) open()
To serialize an object in Java, we typically use _____________________ .
- A) ObjectOutputStream
- B) ClassOutputStream
- C) ClassInputStream
- D) ObjectInputStream
setColor() is a method of ________ object.
- A) JFrame
- B) Graphics
- C) JPanel
- D) Image