Advance Java Programming(Class Test-I)

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Rohini
R
Rohini
Community Contributor
Quizzes Created: 1 | Total Attempts: 6,829
| Attempts: 6,829 | Questions: 25
Please wait...
Question 1 / 25
0 %
0/100
Score 0/100
1. What is the purpose of JTable?

Explanation

The purpose of a JTable object is to display rows and columns of data. It provides a graphical representation of data in a tabular format, allowing users to view and manipulate data in a structured manner.

Submit
Please wait...
About This Quiz
Advance Java Programming(Class Test-I) - Quiz

This 'Advance Java Programming(Class Test-I)' assesses knowledge in Java Swing components, AWT subclasses, and JTable functionalities. It tests understanding of event handling and applet creation, crucial for developing... see morerobust Java applications. Ideal for learners aiming to enhance their Java GUI development skills. see less

2. Which of these are constants defined in WindowEvent class?

Explanation

The constants WINDOW_ACTIVATED, WINDOW_CLOSED, and WINDOW_DEICONIFIED are all defined in the WindowEvent class. These constants represent different types of window events that can occur, such as when a window is activated, closed, or deiconified. By including "All of the above" as the answer, it indicates that all of these constants are defined in the WindowEvent class.

Submit
3. Which of following are subclasses of java.awt.Component?

Explanation

The correct answer is Container. In Java, Container is a class that extends Component and serves as a base class for components that can contain other components. It provides methods for managing and organizing the layout of its child components. LayoutManager, Color, and Font are not subclasses of Component. LayoutManager is an interface used to define the layout behavior of containers, while Color and Font are classes used for specifying colors and fonts in graphical components.

Submit
4. How to create TextArea with 50 rows & 80 columns ?

Explanation

The correct answer is new TextArea(50,80) because the first parameter of the TextArea constructor represents the number of rows and the second parameter represents the number of columns. Therefore, by passing 50 as the number of rows and 80 as the number of columns, we create a TextArea with 50 rows and 80 columns.

Submit
5. The method in ActionEvent................................. returns actionCommand of the button

Explanation

The method getActionCommand() is used in the ActionEvent class to retrieve the action command of the button. This method returns a String that represents the command associated with the event source. In this case, it is used to retrieve the action command of the button that triggered the event. The other methods mentioned, getId(), getModifiers(), and paramString(), do not specifically retrieve the action command and are not relevant to this context.

Submit
6. In swing MVC architecture used in that M stands for

Explanation

In swing MVC architecture, the "M" stands for Model. The Model represents the data and logic of the application. It is responsible for managing the data, performing calculations, and implementing the business logic. The Model interacts with the View and the Controller to update the data and notify the View of any changes. By separating the Model from the View and the Controller, swing MVC architecture promotes modularity and reusability, making it easier to maintain and update the application.

Submit
7. Identify the output of Program:import java.awt.*;import java.awt.event.*;public class MyMenu extends Frame{MenuBar mbr;Menu m1;MenuItem i1,i2;MyMenu(){mbr=new MenuBar();m1=new Menu("File");i1=new MenuItem("About");i2=new MenuItem("Exit");m1.add(i1);m1.add(i2);mbr.add(m1);setMenuBar(mbr);setLayout(new FlowLayout());}public static void main(String args[]){MyMenu m=new MyMenu();m.setSize(400,400);m.setVisible(true);}}

Explanation

The program creates a GUI window using the AWT library. It adds a menu bar to the window with a single menu item "File". The menu item "File" has two sub-items "About" and "Exit". The window is then set to visible. Since there are no other options mentioned in the question, "none of the above" is the correct answer.

Submit
8. Swing components are

Explanation

Swing components are platform independent because they are implemented using Java, which is a platform-independent programming language. This means that Swing components can run on any operating system or platform that supports Java, without requiring any modifications or adaptations. This makes Swing a popular choice for developing cross-platform applications, as it allows developers to write code once and deploy it on multiple platforms without the need for platform-specific implementations.

Submit
9. Which event is generated by List

Explanation

The correct answer is ItemEvent because when a List component is interacted with, such as when an item is selected or deselected, an ItemEvent is generated. This event allows for the detection and handling of changes made to the List component's items.

Submit
10. JCheckBox is component defined in .......................package

Explanation

The correct answer is "swing" because JCheckBox is a component that belongs to the swing package in Java. The swing package provides a set of GUI components that are more flexible and customizable compared to the components in the AWT package. Therefore, if we want to use JCheckBox in our Java program, we need to import the swing package.

Submit
11. MouseDragged() method  present in listener

Explanation

The correct answer is MouseMotionListener because the mouseDragged() method is a part of the MouseMotionListener interface. This interface is used to handle mouse events related to mouse movement, such as dragging the mouse. The other options listed, MouseListener, MouseEvent, and MouseAdapter, do not include the mouseDragged() method.

Submit
12. Which of the following methods can be used to change the size of a Component object?

Explanation

The setSize() method can be used to change the size of a Component object. This method allows you to specify the new width and height of the component. By calling this method, you can dynamically adjust the size of the component based on your requirements.

Submit
13. What Layout manger should you use so that every component occupies the same size in the container?

Explanation

GridLayout is the correct answer because it arranges components in a grid-like manner, where each component occupies the same size in the container. It divides the container into equal-sized cells and each component is placed in a separate cell, ensuring that they all have the same size.

Submit
14. How to disable the default layout manger?

Explanation

The correct answer is setLayout(null). By calling setLayout(null), the default layout manager is disabled and components can be manually positioned and sized using absolute coordinates.

Submit
15. In given constructor 3rd parammeter is ScrollBar(int,int,int,int,int)

Explanation

The correct answer is thumbSize. In the given constructor, the third parameter represents the size of the thumb in the scroll bar. This parameter determines how much of the scroll bar is occupied by the thumb, which is used to indicate the current position within the scrollable content.

Submit
16. The default orientation to display the progress bar is?

Explanation

The default orientation to display the progress bar is horizontal. This means that the progress bar will be displayed as a horizontal line, with the progress increasing from left to right. This orientation is commonly used to visually represent the completion of a task or the progress of a process.

Submit
17. Identify missing statement:-import java.awt.*;import java.applet.*;import javax.swing.*;public class Combo extends JApplet{    public void init()    {        Container c=getContentPane();        JComboBox jc=new JComboBox();        jc.addItem("AJP");        jc.addItem("STE");        jc.addItem("AMI");        jc.addItem("EDP");          }}/*<applet code="Combo.class" height=200 width=200></applet>*/

Explanation

The missing statement in the given code is "c.add(jc);". This statement adds the JComboBox component "jc" to the Container "c". It is necessary to add the JComboBox to the Container in order to display it in the applet.

Submit
18. Which abstract class is the super class of all menu related classes?

Explanation

The correct answer is MenuComponent. MenuComponent is the abstract class that serves as the superclass for all menu-related classes. This means that all other menu-related classes, such as MenuBar, MenuItem, and CheckboxMenuItem, inherit from MenuComponent and can be considered subclasses of it. Therefore, MenuComponent is the correct answer as it is the superclass that provides common functionality and attributes to all menu-related classes.

Submit
19. Find missing statement in program:import java.awt.event.*;import javax.swing.*;import java.awt.*;public class JButtonInAction extends JFrame implements .........................{  JButton rb, gb, bb ;  Container c;  public JButtonInAction( )  {    c = getContentPane();                  c.setLayout(new FlowLayout());              rb = new JButton("Red");    gb = new JButton("Green");    bb = new JButton("Blue");     rb.add................................(this);                  gb.addActionListener(this);    bb.addActionListener(this);     c.add(rb);    c.add(gb);  ................. ;                          setTitle("Buttons In Action");                setSize(300, 350);    setVisible(true);  }                                 public void actionPerformed(ActionEvent e)  {     String str = ........................................        if(str.equals("Red"))                               c.setBackground(Color.red);               else if(str.equals("Green"))                                      c.setBackground(Color.green);     else if(str.equals("Blue"))                                      c.setBackground(Color.blue);  }  public static void main(String args[])  {    new JButtonInAction();    }}

Explanation

The missing statement in the program is "bb.addActionListener(this);". This statement adds the ActionListener to the JButton "bb", so that when the button is clicked, the actionPerformed method will be called. This allows the program to perform certain actions based on the button that was clicked. Additionally, "e.getActionCommand()" is used to retrieve the text of the button that was clicked, which is then used in the if-else statements to determine the background color to set.

Submit
20. What component is needed to get following output?

Explanation

A JList component is needed to get the given output. JList is a Swing component that displays a list of items, allowing the user to select one or more items from the list. It is commonly used to display a list of choices for the user to select from. In this case, the output is a list of choices, so a JList component would be the appropriate choice.

Submit
21. Event is called as?

Explanation

The correct answer is "object that describe a state change in source". In event-driven programming, an event is an object that represents a specific occurrence or action that triggers a response in the program. This response could involve a change in the state of the program or the execution of a specific function. The term "source" refers to the entity or component that generates the event. Therefore, an event is an object that describes a state change in the source, indicating that something has happened and needs to be handled or responded to.

Submit
22. Identify missing statements:import java.awt.*;import java.applet.*;public class Combo extends JApplet{    public void init()    {        Container c=getContentPane();        JComboBox jc=new JComboBox();        jc.addItem("AJP");        jc.addItem("STE");        jc.addItem("AMI");        jc.addItem("EDP");           }}/*<applet ="Combo.class" height=200 width=200></applet>*/

Explanation

The missing statements in the given code are "javax.swing.*;" and "c.add(jc);". These statements are necessary to import the javax.swing package and add the JComboBox component to the container.

Submit
23. MutableTreeNode is extends.................. interface

Explanation

The correct answer is TreeNode because MutableTreeNode is a class that extends the TreeNode interface. The TreeNode interface is a fundamental interface in the Java Swing library that represents a node in a tree data structure. Therefore, it is correct to say that MutableTreeNode extends the TreeNode interface.

Submit
24. What components needed to get following output?

Explanation

To get the following output, the components needed are a Panel, a TabbedPane, and a List. These components can be used to create a graphical user interface with multiple tabs and a list of items. The Panel can serve as the main container for the other components, while the TabbedPane allows for organizing content into different tabs. The List component can display a list of items that can be selected or interacted with by the user.

Submit
25. Which method you can set or change the text in a Label?

Explanation

Both A & B are correct because the setText() method is used to set or change the text in a Label, while the getText() method is used to retrieve the text from a Label. Therefore, both methods can be used to manipulate the text in a Label.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 22, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 25, 2017
    Quiz Created by
    Rohini
Cancel
  • All
    All (25)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is the purpose of JTable?
Which of these are constants defined in WindowEvent class?
Which of following are subclasses of java.awt.Component?
How to create TextArea with 50 rows & 80 columns ?
The method in ActionEvent................................. returns...
In swing MVC architecture used in that M stands for
Identify the output of Program:import java.awt.*;import...
Swing components are
Which event is generated by List
JCheckBox is component defined in .......................package
MouseDragged() method  present in listener
Which of the following methods can be used to change the size of a...
What Layout manger should you use so that every component occupies the...
How to disable the default layout manger?
In given constructor 3rd parammeter is ScrollBar(int,int,int,int,int)
The default orientation to display the progress bar is?
Identify missing statement:-import java.awt.*;import...
Which abstract class is the super class of all menu related classes?
Find missing statement in program:import java.awt.event.*;import...
What component is needed to get following output?
Event is called as?
Identify missing statements:import java.awt.*;import...
MutableTreeNode is extends.................. interface
What components needed to get following output?
Which method you can set or change the text in a Label?
Alert!

Advertisement