Java AWT Basics Quiz
48 Questions
6 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which method is correctly used to set the color in a Graphics context?

  • g.setColor(Color.cyan); (correct)
  • g.setColor(“cyan”); (correct)
  • g.setColor(“Color.cyan”);
  • g.setCurrentColor(cyan);

What is the purpose of the second parameter in the Lable(String, int) constructor?

  • It specifies the alignment of text in the label.
  • It determines the label's background color.
  • It specifies the width of the label in pixels. (correct)
  • It specifies the height of the label.

Which AWT component is best suited for providing a compact, multi-choice selection?

  • Panel
  • TextArea
  • Choice (correct)
  • List

In AWT, which control is typically used for a binary ON/OFF switch?

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

What does the following line of code achieve? TextField tf = new TextField(10);

<p>It establishes a character capacity of 10. (D)</p> Signup and view all the answers

Which class contains the setBackground() method in the java.awt package?

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

What are the properties defined in the Dimension class?

<p>length and width (D)</p> Signup and view all the answers

Frame is a standard window, which is a __________ of the Window class in the AWT hierarchy?

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

In which scenario do both AWT and Swing components create a process?

<p>Both AWT and Swing create a process. (A)</p> Signup and view all the answers

What is the method to set the title of a Frame window?

<p>void setTitle(String str) (D)</p> Signup and view all the answers

Which class is utilized to represent a single line textbox with password character facility?

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

What type of component is a Panel in Java programming?

<p>A window without a title bar or menubar. (B)</p> Signup and view all the answers

If a Button is added to a Panel with a specific font setting, which font will be used for the Button’s label if the Frame's font is different?

<p>The Button's label will use the Panel’s font setting. (A)</p> Signup and view all the answers

Which method is specifically used to set the password character for a TextField?

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

The method getContentPane() is associated with which class in Java's AWT/Swing?

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

What is the default minimum value when creating a ScrollBar in Java with the parameters ScrollBar s = new ScrollBar(0,10,20,0,1000);

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

What is the purpose of the method Container getContentPane()?

<p>Returns a ContentPane for Applet (B)</p> Signup and view all the answers

Which of the following methods is not applicable for buttons in Swing?

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

Which method is used to retrieve the icon of a JButton?

<p>ImageIcon getIcon() (C)</p> Signup and view all the answers

Which of the following is not a component of the Swing library?

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

Which components provide support for two-state functionality?

<p>JCheckBox, JRadioButton (B)</p> Signup and view all the answers

What action is required before implementing the Listener interface?

<p>Override necessary methods (D)</p> Signup and view all the answers

What method is used in the Graphics class to set the current color?

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

Which option describes an incorrect statement regarding the Model-View-Controller (MVC) design pattern?

<p>View retrieves data directly from the database. (B)</p> Signup and view all the answers

Which exception can the constructor of URL throw?

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

What is considered a multicast IP address?

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

Which parameters uniquely identify a connection?

<p>Local IP, Local PORT, Remote IP, Remote PORT and Protocol (D)</p> Signup and view all the answers

Which classes of Java enable connection-oriented communication?

<p>Socket and ServerSocket (C)</p> Signup and view all the answers

How many clients can a server socket connect to at once?

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

Which method is used to create a URL connection?

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

Which method of the DatagramPacket class is used to find the destination address?

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

What is the correct format for a valid local IP address?

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

Which method is used to obtain the IP address associated with a hostname?

<p>getByName(String host_name) (D)</p> Signup and view all the answers

Which of the following is NOT a method defined for InetAddress?

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

Which constructor of DatagramPacket is specifically used for receiving data?

<p>DatagramPacket(byte data[], int size, InetAddress ip, int port) (D)</p> Signup and view all the answers

Which class is responsible for creating a listening port on the server side?

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

Which of the following statements about getByName method is true?

<p>It is reliable and connection-oriented. (A)</p> Signup and view all the answers

What type of class is Permission in the java.security package?

<p>It provides access control mechanisms. (D)</p> Signup and view all the answers

Which DatagramPacket constructor can be used for sending data?

<p>DatagramPacket(byte data[], int size, InetAddress ip, int port) (C)</p> Signup and view all the answers

Which method of InetAddress retrieves the IP address as a string?

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

What does the code 'smt = con.createStatement()' achieve?

<p>A Statement object is created to send SQL commands to the database. (B)</p> Signup and view all the answers

Which method can be used to send SQL statements?

<p>Both B &amp; C (B)</p> Signup and view all the answers

Which driver converts JDBC calls into calls on the Client API for various databases?

<p>Native API partly – Java Driver (D)</p> Signup and view all the answers

Which method executes an SQL statement that may return multiple results?

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

Which format is used for Microsoft Access data files?

<p>.MDB (D)</p> Signup and view all the answers

How is a DELETE statement in SQL executed?

<p>using executeUpdate() (C)</p> Signup and view all the answers

What is the interface that handles communication with the database?

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

What is created when a CallableStatement is prepared?

<p>A parameterized SQL command (D)</p> Signup and view all the answers

Flashcards

ScrollBar Initial Value

The scroll bar's initial value. It determines the position of the scroll bar's thumb when it's first displayed.

ScrollBar Increment Value

The amount by which the scroll bar's thumb moves with each click on the scroll arrows.

ScrollBar Minimum Value

The minimum value that the scroll bar can represent. It sets the lower bound for scrolling.

What is a Panel?

A subclass of Container that acts as a blank area inside a window or applet. It doesn't have its own title bar, menu bar, or border.

Signup and view all the flashcards

Button's Font Inheritance

It refers to the font used to display the button's label. If the button's font isn't explicitly set, it inherits the font of its parent container (the panel in this case).

Signup and view all the flashcards

How to Set a Frame's Title

This method, setTitle(), is part of the Frame class. It sets the title that appears in the window's title bar.

Signup and view all the flashcards

Setting Password Characters in a TextField

This method, setEchoChar(), is used to display a specific character (often an asterisk) instead of the actual characters typed into a text field. It's primarily used for password fields.

Signup and view all the flashcards

What is the Purpose of getContentPane() Method?

The getContentPane() method is a member of the JFrame class. It returns a reference to the content pane of the JFrame. The content pane is the area where you add components to a JFrame window (think of it as the main container inside the JFrame).

Signup and view all the flashcards

Panel Class

A concrete subclass of Container in AWT, providing a blank area for drawing or adding components.

Signup and view all the flashcards

g.setColor()

A method used to set the color for drawing on a Graphics object in AWT.

Signup and view all the flashcards

Frame

A standard window in AWT. It is a top-level container having a title bar, menu bar, and a border.

Signup and view all the flashcards

List Component

A component in AWT that provides a scrollable, compact, multi-choice selection area.

Signup and view all the flashcards

TextField Component

A component in AWT that displays a single line of text that can be edited by the user.

Signup and view all the flashcards

setBackground() Method

A method in the Component class that allows you to change the background color of a component.

Signup and view all the flashcards

java.awt Package

The package in Java that provides the foundation for Graphical User Interfaces (GUIs).

Signup and view all the flashcards

Dimension Class

A class in the java.awt package that defines length and width attributes.

Signup and view all the flashcards

getContentPane() in Swing

A method used within Swing to retrieve the ContentPane of an Applet. It allows access to the Applet's main display area, where components can be added or manipulated.

Signup and view all the flashcards

Which method is not applicable for buttons in Swing?

The setSelectedIcon() method is not applicable to buttons in Swing. Although related, it's used with components allowing state changes, like checkboxes or radio buttons, to adjust their appearance based on their selected state.

Signup and view all the flashcards

How to retrieve the icon of a JButton?

The getIcon() method, returning an ImageIcon, is used in Swing to retrieve the icon from a JButton. It allows you to access and potentially modify the button's visual representation.

Signup and view all the flashcards

Which Swing components support two states?

Swing components like JCheckBox and JRadioButton, which allow two states (checked or unchecked), provide support for two-state visual representation. This means they can visually reflect whether they are currently selected or not.

Signup and view all the flashcards

Which Graphics method sets the current graphics color?

The setColor() method of the Graphics class, used for drawing in Java, sets the current drawing color to the specified color. This determines the color any future drawing operations will use.

Signup and view all the flashcards

MalformedURLException

A URL that is malformed (incorrect format) will throw a MalformedURLException when you try to create a URL object from it.

Signup and view all the flashcards

Multicast IP Address

A multicast IP address falls within the range of 224.0.0.0 to 239.255.255.255. These addresses are used to send data to multiple destinations simultaneously.

Signup and view all the flashcards

Connection Identifiers

A network connection is uniquely identified by these parameters: Local IP (your computer's address), Local Port (your app's specific port), Remote IP (the server's address), Remote Port (the service on the server), and the protocol being used (like TCP or UDP).

Signup and view all the flashcards

URL Object Creation

The URL class in Java provides a way to create a URL object from a given string URL address.

Signup and view all the flashcards

DatagramPacket Destination Address

The DatagramPacket class's getAddress() method is used to retrieve the destination address that's been set for a DatagramPacket object.

Signup and view all the flashcards

Connection-Oriented Communication

Socket programming in Java utilizes the Socket and ServerSocket classes for creating connection-oriented communication. These classes establish reliable, persistent connections between clients and servers.

Signup and view all the flashcards

Server Socket Clients

A single server socket can potentially connect to numerous clients, allowing multiple clients to interact with the server simultaneously.

Signup and view all the flashcards

URL Connection Creation Method

The URL class in Java doesn't directly have a built-in create() method. Instead, you create a URL object by using the URL class constructor.

Signup and view all the flashcards

InetAddress getByName(String host_name)

This method is used to get the host address of a given host name, returning an InetAddress object.

Signup and view all the flashcards

InetAddress[] getAllByName(String host_name)

This method is used to retrieve all possible IP addresses associated with a given host name, returning an array of InetAddress objects.

Signup and view all the flashcards

String getHostAddress()

This method retrieves the string representation of the IP address of the InetAddress object.

Signup and view all the flashcards

URLConnection

This class provides methods for working with URLs, including getting content length, last modification date, and expiration date.

Signup and view all the flashcards

ServerSocket

This class is used to create a server socket, which listens for incoming connections on a specified port.

Signup and view all the flashcards

DatagramPacket

This class is used to represent a datagram packet, which is a unit of data sent or received over a network.

Signup and view all the flashcards

Receiving DatagramPacket Constructor

The following constructor DatagramPacket(byte data[ ], int size, InetAddress ip, int port) is used for receiving purpose.

Signup and view all the flashcards

Permission Class

The Permission class is used to represent access permissions in the Java security model.

Signup and view all the flashcards

createStatement() in JDBC

A PreparedStatement object is created to send SQL commands to the database.

Signup and view all the flashcards

JDBC ODBC Bridge + ODBC Driver

This driver uses a combination of a JDBC-ODBC bridge and an ODBC driver to convert JDBC calls into calls on the Client API for different DBMS.

Signup and view all the flashcards

executeUpdate() in JDBC

The executeUpdate() method is used to execute an SQL statement that may return multiple results.

Signup and view all the flashcards

executeQuery() in JDBC

The executeQuery() method is used to execute a SELECT statement and return results.

Signup and view all the flashcards

CallableStatement in JDBC

A CallableStatement object is created to send SQL commands to the database. It allows you to execute stored procedures and functions.

Signup and view all the flashcards

execute() in JDBC

The execute() method is used to execute an SQL statement and receive a result.

Signup and view all the flashcards

Microsoft Access data format

Microsoft Access databases use the .MDB file format.

Signup and view all the flashcards

JDBC Interface

The JDBC interface handles the communication between the application and the database.

Signup and view all the flashcards

Study Notes

Advanced Java Programming Study Notes

  •  Textbook Edition: 2019
  • Curriculum: Strictly adheres to the revised syllabus of 'I' Scheme, effective from academic year 2018-2019
  • Institution: Maharashtra State Board of Technical Education
  • Subject: Advanced Java Programming
  • Course Code: 22517
  • Course Level: Semester V, Computer Engineering (CO/CM/CW)
  • Author: Ravi Majithia
  • Material Type: Free MCQ Booklet for Online Examinations

Features

  • MCQs: Over 250 multiple-choice questions.
  • Structure: Questions organized chapterwise.
  • Purpose: Specifically designed for online examinations adhering to 'I' Scheme.

Index of MCQs (Page 3)

  • Unit I: (AWT) - M1-1 to M1-5
  • Unit II: Swings - M2-1 to M2-2
  • Unit III: Event Handling - M3-1 to M3-3
  • Unit IV: Networking Basics - M4-1 to M4-3
  • Unit V: Interacting with Database - M5-1 to M5-3
  • Unit VI: Servlets - M6-1 to M6-3

Chapter 1: Abstract Windowing Toolkit (AWT) (Page 5)

  • AWT abbreviation: Abstract Windowing Toolkit
  • Number of AWT controls: 7
  • Passive controls: Do not support user interaction (Choice, List, Checkbox)
  • Label text change method: setText()
  • Pop-up list control: Choice
  • Graphics programming class: java.awt.Graphics
  • Frame creation methods: Association and Inheritance

Additional Chapters (Pages 6-11, 15-17, 18-20, 21-23)

  • Coverage of various Java programming concepts like Swing, Event Handling, Networking, Database Interaction, and Servlets, including related multiple-choice questions.

Studying That Suits You

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

Quiz Team

Related Documents

Description

Test your knowledge of Java's Abstract Window Toolkit (AWT) with this quiz. Answer questions about components, constructors, and methods used in AWT. Get ready to prove your understanding of GUI programming in Java!

More Like This

AWT Quiz
10 questions

AWT Quiz

OutstandingSanctuary avatar
OutstandingSanctuary
Java AWT and Event Driven Programming Quiz
10 questions
Java AWT Unit 1 Quiz
32 questions

Java AWT Unit 1 Quiz

SupportingPulsar avatar
SupportingPulsar
Use Quizgecko on...
Browser
Browser