Advance Java Programming(Class Test-I)

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Rohini
R
Rohini
Community Contributor
Quizzes Created: 1 | Total Attempts: 6,599
Questions: 25 | Attempts: 6,611

SettingsSettingsSettings
Advance Java Programming(Class Test-I) - Quiz


Questions and Answers
  • 1. 

    Swing components are

    • A.

      Platform dependent

    • B.

      Platform independent

    • C.

      Both a & b

    • D.

      Platform Oriented

    Correct Answer
    B. Platform independent
    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.

    Rate this question:

  • 2. 

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

    • A.

      Container

    • B.

      LayoutManger

    • C.

      Color

    • D.

      Font

    Correct Answer
    A. Container
    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.

    Rate this question:

  • 3. 

    What is the purpose of JTable?

    • A.

      JTAble object displays rows of data

    • B.

      JTAble object displays columns of data

    • C.

      JTAble object displays rows and columns of data

    • D.

      JTAble object displays data in Tree form

    Correct Answer
    C. JTAble object displays rows and columns of data
    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.

    Rate this question:

  • 4. 

    Which of these are constants defined in WindowEvent class?

    • A.

      WINDOW_ACTIVATED

    • B.

      WINDOW_CLOSED

    • C.

      WINDOW_DEICONIFED

    • D.

      All of the above

    Correct Answer
    D. All of the above
    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.

    Rate this question:

  • 5. 

    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>*/

    • A.

      Add(jc);

    • B.

      Jc.add(c);

    • C.

      c.add(jc);

    • D.

      Add(c);

    Correct Answer
    C. c.add(jc);
    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.

    Rate this question:

  • 6. 

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

    • A.

      MenuComponent

    • B.

      MenuBar

    • C.

      MenuItem

    • D.

      CheckboxMenuItem

    Correct Answer
    A. MenuComponent
    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.

    Rate this question:

  • 7. 

    In swing MVC architecture used in that M stands for

    • A.

      Main

    • B.

      Mulit-level

    • C.

      Model

    • D.

      Method

    Correct Answer
    C. Model
    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.

    Rate this question:

  • 8. 

    The default orientation to display the progress bar is?

    • A.

      CENTER

    • B.

      TOP

    • C.

      HORIZONTAL

    • D.

      VERTICAL

    Correct Answer
    C. HORIZONTAL
    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.

    Rate this question:

  • 9. 

    Which event is generated by List

    • A.

      ActionEvent

    • B.

      MouseEvent

    • C.

      ItemEvent

    • D.

      KeyEvent

    Correct Answer
    C. ItemEvent
    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.

    Rate this question:

  • 10. 

    MutableTreeNode is extends.................. interface

    • A.

      TreePath

    • B.

      TreeNode

    • C.

      DefaultMutableTreeNode

    • D.

      MutableTreeNode

    Correct Answer
    B. TreeNode
    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.

    Rate this question:

  • 11. 

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

    • A.

      FlowLayout

    • B.

      GridLayout

    • C.

      CardLayout

    • D.

      BorderLayout

    Correct Answer
    B. GridLayout
    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.

    Rate this question:

  • 12. 

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

    • A.

      Setsize()

    • B.

      SetSize()

    • C.

      GetSize()

    • D.

      Size()

    Correct Answer
    B. SetSize()
    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.

    Rate this question:

  • 13. 

    How to create TextArea with 50 rows & 80 columns ?

    • A.

      New TextArea(80,50);

    • B.

      New TextArea(50,80);

    • C.

      New TextArea(80);

    • D.

      TextArea(80,50);

    Correct Answer
    B. New TextArea(50,80);
    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.

    Rate this question:

  • 14. 

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

    • A.

      Height

    • B.

      Width

    • C.

      ThumbSize

    • D.

      Boxsize

    Correct Answer
    C. ThumbSize
    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.

    Rate this question:

  • 15. 

    Event is called as?

    • A.

      Object that describe a state change in processing

    • B.

      Object that describe any change by the user and system

    • C.

      Event is class defining only object

    • D.

      Object that describe a state change in source

    Correct Answer
    D. Object that describe a state change in source
    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.

    Rate this question:

  • 16. 

    MouseDragged() method  present in listener

    • A.

      MouseListener

    • B.

      MouseEvent

    • C.

      MouseMotionListener

    • D.

      MouseAdapter

    Correct Answer
    C. MouseMotionListener
    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.

    Rate this question:

  • 17. 

    JCheckBox is component defined in .......................package

    • A.

      Awt

    • B.

      Net

    • C.

      Javax

    • D.

      Swing

    Correct Answer
    D. Swing
    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.

    Rate this question:

  • 18. 

    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);}}

    • A.

      Option 1

    • B.

      Option 2

    • C.

      Option 3

    • D.

      None of the above

    Correct Answer
    C. Option 3
    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.

    Rate this question:

  • 19. 

    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>*/

    • A.

      Code; javax.swing.*; c.add(jc);

    • B.

      Javax.swing.*; c.add(jc); code

    • C.

      Javax.swing.*;

    • D.

      C.add(j);

    Correct Answer
    B. Javax.swing.*; c.add(jc); code
    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.

    Rate this question:

  • 20. 

    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();    }}

    • A.

      ActionListener , c.add(bb); , ,ActionListener, e.getActionCommand();

    • B.

      c.add(bb); ,ActionListener ,ActionListener, c.add(bb);

    • C.

      ActionListener ,ActionListener, c.add(bb); , e.getActionCommand();

    • D.

      ActionListener, c.add(bb); , e.getActionCommand();

    Correct Answer
    C. ActionListener ,ActionListener, c.add(bb); , e.getActionCommand();
    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.

    Rate this question:

  • 21. 

    What components needed to get following output?

    • A.

      TabbedPane,List,Applet

    • B.

      Applet,TabbedPane,Panel

    • C.

      Panel,TabbedPane,List

    • D.

      Applet,Panel,TabbedPane

    Correct Answer
    C. Panel,TabbedPane,List
    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.

    Rate this question:

  • 22. 

    What component is needed to get following output?

    • A.

      Choice

    • B.

      List

    • C.

      JList

    • D.

      JCombobox

    Correct Answer
    C. JList
    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.

    Rate this question:

  • 23. 

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

    • A.

      SetText()

    • B.

      GetText()

    • C.

      Both A & B

    • D.

      None of above

    Correct Answer
    C. Both A & B
    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.

    Rate this question:

  • 24. 

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

    • A.

      GetId()

    • B.

      GetActionCommand()

    • C.

      GetModifiers()

    • D.

      ParamString()

    Correct Answer
    B. GetActionCommand()
    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.

    Rate this question:

  • 25. 

    How to disable the default layout manger?

    • A.

      SetLayout(false);

    • B.

      SetLayout();

    • C.

      SetLayout(null);

    • D.

      Setnull();

    Correct Answer
    C. SetLayout(null);
    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.

    Rate this question:

Quiz Review Timeline +

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
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.