Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.(TCOs 1, 3, and 6) Which of the following statements is true? Constructors can

ID: 2246567 • Letter: 1

Question

1.(TCOs 1, 3, and 6) Which of the following statements is true?
Constructors can specify parameters and return types.
Constructors can specify parameters but not return types.
Constructors cannot specify parameters but can specify return types.
Constructors can specify neither parameters not return types.

2.(TCOs 1, 3, and 6) The _____ class can be used to get user input using dialog boxes.
JFrame
Scanner
JPanel
JOptionPane

3. (TCOs 1, 3, and 6) Which of the following statements is used to terminate the program when closing the frame?
frame.setDefaultCloseOperation(null);
frame.setDefaultCloseOperation(JFrame.STOP_ON_CLOSE);
frame.setDefaultCloseOperation(JFrame.TERMINATE_ON_CLOSE)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

4.(TCOs 1, 3, and 6) Suppose a JFrame uses GridLayout(0,2). If you add six buttons to the frame, how many rows are displayed?
1
2
3
4

5.(TCOs 1, 3, and 6) Object-oriented programming allows you to derive new classes from existing classes. This is called
composition.
interfaces.
inheritance
polymorphism

6.(TCOs 1, 3, and 6) The implements keyword in a class declaration indicates the use of
interfaces
polymorphism.
composition
inheritance

7.(TCOs 1, 3, and 6) AWT

is the oldest Java GUI library.
uses the native widgets from the operating system
is not recommended for modern application development due to programs with cross-platform portability.
All of the above

8.(TCOs 1, 3, and 6) What component can be used for user input or display of output?
JButton
JLabel
JTextField
JFrame

9.(TCOs 1, 3, and 6) Which of the following statements will display ìHello Worldî in a label named lblMessage?
lblMessage.setLabel(ìHello Worldî);
lblMessage(ìHello Worldî);
lblMessage.setText(ìHello Worldî);
lblMessage.getText(ìHello Worldî

10.(TCOs 1, 3, and 6) Every event object has the _____ method that can be used to identify the component that triggered the event.
getSource()
getAction()
getTrigger()
getComponent()

Explanation / Answer


1.(TCOs 1, 3, and 6) Which of the following statements is true?

Ans)Constructors can specify parameters but not return types.

Reason: Parameterized constructor is used to initialize the instance variables but there is no return type for the Constructor.

_______________

2.(TCOs 1, 3, and 6) The _____ class can be used to get user input using dialog boxes.

Ans) JOptionPane

______________

3. (TCOs 1, 3, and 6) Which of the following statements is used to terminate the program when closing the frame?

Ans) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)

_______________

4.(TCOs 1, 3, and 6) Suppose a JFrame uses GridLayout(0,2). If you add six buttons to the frame, how many rows are displayed?

Ans)2

______________

5.(TCOs 1, 3, and 6) Object-oriented programming allows you to derive new classes from existing classes. This is called

Ans) inheritance

Reason:Creating new classes from already existing classes is called inheritance.Where already existing classes is called parent class.Newly created class is called Child class.

_________________

6.(TCOs 1, 3, and 6) The implements keyword in a class declaration indicates the use of

Ans) interfaces

_________________

7. AWT

Ans)All of the above

________________

8.(TCOs 1, 3, and 6) What component can be used for user input or display of output?

Ans) JTextField

________________

9) Which of the following statements will display ìHello Worldî in a label named lblMessage?

Ans) lblMessage.setLabel(ìHello Worldî);

________________

10.(TCOs 1, 3, and 6) Every event object has the _____ method that can be used to identify the component that triggered the event.

Ans) getComponent()

__________________Thank You