Java Applet Programming Quiz
39 Questions
4 Views

Java Applet Programming Quiz

Created by
@MatchlessClavichord

Questions and Answers

What does AWT stand for?

  • All windows Tools
  • Abstract Window Toolkit (correct)
  • All Window Toolkit
  • All writing Tools
  • Which event is generated when a button is pressed?

  • FocusEvent
  • KeyEvent
  • ActionEvent (correct)
  • WindowEvent
  • Which method is used to change the location of an event?

  • isPopupTrigger()
  • getClickCount()
  • getPoint()
  • translatePoint() (correct)
  • What is the return type of actionPerformed(ActionEvent e)?

    <p>void</p> Signup and view all the answers

    What types of dialog boxes are there?

    <p>Modal &amp; Modeless</p> Signup and view all the answers

    Which method can be used on any instance of java.awt.Component?

    <p>SetForeground</p> Signup and view all the answers

    Which class serves as the superclass of all events in Java?

    <p>EventObject</p> Signup and view all the answers

    What is the default layout manager for a Panel or Applet?

    <p>Flow Layout</p> Signup and view all the answers

    Which method will be called when a character is typed in an input component?

    <p>KeyTyped()</p> Signup and view all the answers

    What is the correct way to set a label's text in Java using jlbl variable?

    <p>jlbl.setText(&quot;Result&quot;)</p> Signup and view all the answers

    Which package is required to use Swing components?

    <p>javax.Swing</p> Signup and view all the answers

    Which of the following constructors is used to create a JButton with a label?

    <p>JButton(String str)</p> Signup and view all the answers

    What type of component can be styled with their own look and feel in Java?

    <p>Swing</p> Signup and view all the answers

    Which object is required to group Checkboxes to ensure only one can be selected at a time?

    <p>CheckboxGroup</p> Signup and view all the answers

    What class represents a Checkbox with a textual label in a menu?

    <p>CheckBoxMenuItem</p> Signup and view all the answers

    Which layout is the default for both JPanel and Applet?

    <p>FlowLayout</p> Signup and view all the answers

    Which method cannot be called on a JLabel object?

    <p>setBorderLayout()</p> Signup and view all the answers

    Which pane can be utilized to add components to a container?

    <p>ContentPane</p> Signup and view all the answers

    What is the primary purpose of a JTable?

    <p>Displays both rows and columns of data</p> Signup and view all the answers

    Which of the following is a valid AWT control?

    <p>Push Buttons</p> Signup and view all the answers

    Which of the following classes is used for GUI components in Java?

    <p>Panel</p> Signup and view all the answers

    What is the default layout for JFrame?

    <p>BorderLayout</p> Signup and view all the answers

    Which class components can display icons in addition to strings?

    <p>JTree</p> Signup and view all the answers

    Which layout is used to arrange components in a rectangular area?

    <p>BorderLayout</p> Signup and view all the answers

    What is the return type of the getSelectedItem method in the choice class?

    <p>void</p> Signup and view all the answers

    Which method triggers adjustmentValueChanged in AdjustmentListener interface?

    <p>adjustmentValueChanged()</p> Signup and view all the answers

    What is the return type of the getRed() method?

    <p>Color</p> Signup and view all the answers

    Which listener interface does the Button class implement?

    <p>ActionListener</p> Signup and view all the answers

    What is the return type of the getItemCount() method?

    <p>int</p> Signup and view all the answers

    Which class uses the constants BLOCK_DECREMENT and BLOCK_INCREMENT?

    <p>Scrollbar</p> Signup and view all the answers

    What is the default layout for Applet?

    <p>FlowLayout</p> Signup and view all the answers

    Which interface does JToggleButton implement?

    <p>AbstractButton</p> Signup and view all the answers

    Which method is used to obtain a reference to the JCheckBox object that generated the event?

    <p>getSelectedItem()</p> Signup and view all the answers

    In Swing, a Radio Button is created using which component?

    <p>ButtonGroup</p> Signup and view all the answers

    What does the following line of code do? 'TextField t=new TextField(10);'

    <p>Creates an object that can hold 10 columns of text</p> Signup and view all the answers

    The setBackground() method() is a part of which class in the java.awt package?

    <p>Container</p> Signup and view all the answers

    Which method can be used to remove a java.awt.Component object from display?

    <p>remove()</p> Signup and view all the answers

    What are controls or components in a user interface?

    <p>Components allow users to interact with application</p> Signup and view all the answers

    Which of the following can be considered subclasses of Swing components?

    <p>Jpanel</p> Signup and view all the answers

    Study Notes

    Applet Output Methods

    • Use drawString() method to output a string in an applet.

    AWT Overview

    • AWT stands for Abstract Window Toolkit.

    User Interaction Events

    • ActionEvent is generated when a button is pressed.

    JDK Structure

    • AWT Viewer tool is found in the bin folder of JDK.

    Event Handling

    • setAlignment() returns type void.
    • Use translatePoint() method to change the location of an event.
    • actionPerformed(ActionEvent e) returns type void.
    • itemStateChanged(ItemEvent ie) returns type int.

    Dialog Boxes

    • Types of dialog boxes include Model & Modeless.

    Font and Style

    • Use Font.BOLD + Font.ITALIC to specify a font styled as both bold and italic.

    Component Methods

    • Use setForeground, setBackground, and setFont methods on java.awt.Component instances.
    • TextField can be used to enter or display a string.
    • Use jlbl.setText("Result") method to assign the name 'Result' to jlbl.

    Key Press Methods

    • KeyTyped() method is invoked if a character is entered.

    Event Classes Hierarchy

    • Applet is the super class of all adapter classes.
    • ComponentEvent is the super class of all ContainerEvent classes.
    • EventObject serves as the super class of all events.

    Swing Components

    • Swing allows components to have their own look and feel.
    • To create a button with a label, use JButton(String str) constructor.
    • Use javax.swing package to utilize Swing components.

    Layout Managers

    • Default layout manager for Panel or Applet is FlowLayout.
    • BorderLayout is the default layout manager for Frame and JFrame.
    • GridLayout is utilized for arranging components in a 3-dimensional array.

    Color Methods

    • getRed(), getGreen(), and getBlue() return type Color.

    Button and CheckBox Interfaces

    • Button class implements ActionListener.
    • CheckBox class implements ItemListener.
    • ScrollBar implements AdjustmentListener.

    Action Events and Listeners

    • ActionEvent belongs to Button class.
    • addTab() method belongs to JTabbedPane.
    • getPath() returns type TreePath.

    Tree Nodes and Interfaces

    • DefaultMutableTreeNode implements MutableTreeNode.
    • getIcon() method return type is Icon.

    Radio Buttons and Check Boxes

    • ButtonGroup is used to create radio buttons.
    • Exclusive checkboxes require CheckboxGroup.

    Control Classes

    • Various AWT controls include Labels, Push buttons, Checkboxes, and Choice lists.

    JPanel and Default Layouts

    • JPanel and Applet use FlowLayout as their default layout.

    JTable Usage

    • JTable object displays rows and columns of data.

    JLabel Restrictions

    • setBordeLayout() cannot be called on a JLabel object.

    Content Pane

    • ContentPane can be used to add components to a container.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge on Java applet programming concepts with this quiz. It covers various methods, events, and frameworks related to applets and AWT. Challenge yourself and see how well you understand the fundamentals of Java applet development.

    More Quizzes Like This

    AJP ch1
    60 questions

    AJP ch1

    AstonishedMookaite avatar
    AstonishedMookaite
    Applet Programming Basics Quiz
    10 questions

    Applet Programming Basics Quiz

    UserFriendlyCelebration avatar
    UserFriendlyCelebration
    Java Applets
    5 questions

    Java Applets

    UpbeatOwl5159 avatar
    UpbeatOwl5159
    Java and Internet Relationship
    22 questions
    Use Quizgecko on...
    Browser
    Browser