Programming in Java Nptel Week 9 Assignment Answers
Are you looking for Programming in Java Nptel Week 9 Assignment Answers? You’ve come to the right place! Access the latest and most accurate solutions for your Week 9 assignment in the Programming in Java course
Table of Contents
Programming in Java Nptel Week 9 Assignment Answers (Jan-Apr 2025)
Course Link: Click Here
1. Which Swing component is best suited for displaying a drop-down list of selectable options?
a) JButton
b) JComboBox
c) JTextField
d) JPanel
2. What will be the output of the following Java code?
a) A frame with two buttons labeled “Button 1” and “Button 2”
b) A frame with only one button labeled “Button 2”
c) Compilation Error
d) Runtime Error
3. Which of the following is true about the JLabel component in Java Swing?
a) It is used only for displaying text
b) It can display text and icons
c) It cannot be added to a JPanel
d) It generates mouse events by default
Programming in Java Nptel Week 9 Assignment Answers
4. Which method is used to handle mouse click events in Java Swing?
a) mouseClicked()
b) keyPressed()
c) actionPerformed()
d) componentShown()
5. What should replace // INSERT CODE HERE to create a JFrame with a JButton labeled “Click Me”?
a) frame.add(button);
b) frame.insert(button);
c) frame.append(button);
d) frame.push(button);
6. Identify and correct the error in the following program: What should the erroneous line panel.setFlowLayout(); be replaced with?
a) panel.setLayout(new GridLayout());
b) panel.addFlowLayout();
c) panel.appendLayout(new FlowLayout());
d) panel.setLayout(new FlowLayout());
7. What will the following Java program output?
a) A frame with the label “Welcome to Swing”
b) A frame with no visible label
c) Compilation Error
d) Runtime Error
8. What does the following code do?
a) Creates a JFrame with a JButton labeled “Programming in Java”
b) Compiles with errors
c) Displays a message dialog
d) Creates a JPanel with a JButton labeled “Programming in Java”
9. What happens when the button in this Java code snippet is clicked?
a) The program exits
b) A message dialog with the text “Welcome to the course” is displayed
c) The button label changes to “Welcome to the course”
d) Nothing happens
10. The container displays a number of components in a column, with extra space going between the first two components. Which of the following layout manager(s) is most naturally suited for the described layout?
a) BoxLayout
b) FlowLayout
c) BorderLayout
d) GridLayout
These are NPTEL Programming in Java Nptel Week 9 Assignment Answers
More Weeks of Programming In Java: Click here
More Nptel Courses: https://progiez.com/nptel-assignment-answers








