Untitled Quiz
48 Questions
0 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

What is the primary reason for using a layout manager instead of manually laying out components in Java?

  • It provides more control over event handling for components.
  • It simplifies the arrangement of components and handles resizing automatically. (correct)
  • It allows for easier editing of components' properties.
  • It prevents the need to manage component visibility.
  • What method is used to associate a layout manager with a Container object?

  • setLayout() (correct)
  • createLayout()
  • initLayout()
  • setLayoutManager()
  • What happens when you pass null to the setLayout() method?

  • You can manually define the layout using setBounds(). (correct)
  • All components are hidden by default.
  • The default layout manager is activated.
  • The container cannot hold any components.
  • Which of the following constructors for FlowLayout specifies horizontal and vertical gaps between components?

    <p>FlowLayout(int how, int horz, int vert)</p> Signup and view all the answers

    Which of the following methods is primarily associated with the Component class?

    <p>public void setVisible(boolean)</p> Signup and view all the answers

    What is the default alignment for components when using FlowLayout?

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

    Which container cannot contain a title bar and menubars but can still hold buttons or text fields?

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

    Which layout manager is characterized by a flowing layout similar to a text editor?

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

    What type of layout does the FlowLayout manager use by default?

    <p>Row-wise arrangement.</p> Signup and view all the answers

    What is the correct name of the method to alter the layout of a Java container?

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

    Which Swing class is utilized for creating frames in a Java application?

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

    If you want to disable a layout manager in Java, which value should be passed to setLayout()?

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

    Which method will set the text of a Label object in Java?

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

    What event is generated by pressing a button in Java?

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

    Which package contains all the necessary classes and methods for event handling in Java?

    <p>Java.awt.event</p> Signup and view all the answers

    In Java, what term describes an area on the screen bounded by borders and containing various interface elements?

    <p>A frame</p> Signup and view all the answers

    What is the primary function of the List class?

    <p>To create a scrolling selection list for multiple choices</p> Signup and view all the answers

    What does the numRows parameter specify in the List constructor List(int numRows)?

    <p>The number of items always visible in the list</p> Signup and view all the answers

    How do you add a new item to a List at a specific index?

    <p>Using the add(String name, int index) method</p> Signup and view all the answers

    Which method would you use to retrieve the index of the currently selected item in a List?

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

    When implementing the ActionListener interface for a List, what does the getActionCommand() method return?

    <p>The name of the newly selected item</p> Signup and view all the answers

    What will the method getSelectedItem() return if no item has been selected?

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

    Which statement is true regarding the multipleSelect parameter in the List constructor?

    <p>If set to true, multiple items can be selected simultaneously</p> Signup and view all the answers

    What is the purpose of the getItem(int index) method in the List class?

    <p>To retrieve the name of the item at the specified index</p> Signup and view all the answers

    What is the primary purpose of the getConnection method in JDBC?

    <p>To establish a connection to a database</p> Signup and view all the answers

    Which method is used to permanently save changes made in a transaction?

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

    What does the setAutoCommit(boolean status) method do?

    <p>Manages the default transaction behavior</p> Signup and view all the answers

    What is the role of the Stub in RMI programming?

    <p>It acts as a gateway for the client-side</p> Signup and view all the answers

    Which of the following methods would you use to close a JDBC connection?

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

    In RMI, what do the client and server applications interact with to communicate?

    <p>Remote interface</p> Signup and view all the answers

    What does the createStatement(int resultSetType, int resultSetConcurrency) method provide?

    <p>Generates ResultSet objects with specified type and concurrency</p> Signup and view all the answers

    What happens when the rollback() method is called?

    <p>All changes made since the last commit are discarded</p> Signup and view all the answers

    What method is used to change the selection mode of a JList?

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

    What is the primary purpose of the JButton class in Swing?

    <p>To implement a push button</p> Signup and view all the answers

    Which of the following selection modes does NOT exist in ListSelectionModel?

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

    How can you obtain the action command associated with a JButton?

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

    Which class should a Swing applet extend to gain Swing functionality?

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

    What is generated when a JButton is pressed?

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

    Which method must be implemented to handle button press events in a JButton?

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

    When using multiple buttons, how can you identify which button was pressed?

    <p>Through the action command</p> Signup and view all the answers

    What is the primary use of persistent cookies?

    <p>To store long-term information such as user preferences</p> Signup and view all the answers

    Which method of the Cookie class is used to change the value of a cookie?

    <p>public void setValue(String value)</p> Signup and view all the answers

    How does a persistent cookie differ from a session cookie?

    <p>Persistent cookies are valid across multiple sessions</p> Signup and view all the answers

    Which class in the javax.servlet package is used to provide an output stream for sending binary data to the client?

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

    What happens to persistent cookies when they expire?

    <p>They are automatically deleted from the user's device</p> Signup and view all the answers

    Which method returns the name of a cookie?

    <p>public String getName()</p> Signup and view all the answers

    What does the GenericServlet class do?

    <p>Defines a generic and protocol-independent servlet</p> Signup and view all the answers

    What type of notifications does the ServletContextAttributeEvent class generate?

    <p>Changes to servlet context attributes</p> Signup and view all the answers

    Study Notes

    Advanced Java Programming - Question Bank

    • V SEMESTER BCA
    • Course: Advanced Java Programming
    • Course Code: 22CAC-13

    Module I

    • Applet Output Display: The paint() method is used to display applet output.
    • String Output in Applet: The drawString() method is used to output strings within an applet.
    • AWT: Acronym for Abstract Window Toolkit, a Java API for creating graphical user interfaces.
    • Exception in read() method: The read() method can throw an IOException.
    • Input/Output Packages: The java.io package provides classes and interfaces for input/output operations.
    • Non-member class of java.io package: java.io.Writer is not a member class, java.io.StringReader is.
    • Non-input/output related class: java.io.File is not related to input/output stream functionality.
    • Byte Streams: java.io.InputStream and java.io.OutputStream are used for reading and writing byte data.
    • Character Streams: java.io.Reader and java.io.Writer are used for reading and writing character data.

    Module II

    • Container without title bar/menu: A Panel is a container that does not have a title bar or menu bar.
    • Event handling package: java.awt.event provides event classes and listener interfaces for event handling.
    • Rectangle drawing: The drawRect(int x, int y, int width, int height) method in the java.awt.Graphics class draws a rectangle.
    • GUI application window: A Frame is a window that represents a GUI application and can have a title bar, icon, and menus.
    • ActionListener implementation: There are several ways to implement the ActionListener interface: by creating a new class, using an anonymous inner class, etc.

    Module III

    • Graphics methods: The Graphics class provides methods for graphics programming tasks.
    • Label text handling: The setText() method is used to set the text displayed in a Label object.
    • Container layout: A Container's layout can be altered using the setLayout() method, which accepts a LayoutManager object.
    • Key press detection: Use the getKey() method for detecting a pressed key..
    • Methods invoked for button press: An ActionEvent is generated when a button is pressed.
    • Event handling package: java.awt.event is the package containing classes for event handling.
    • GUI window object: A Frame is a visible window in a GUI application.
    • String Label modification: The Label class has a setText() method to change the text of the label.
    • Passive controls: Controls like Labels are passive, they don't respond to user interaction directly.

    Module IV - JDBC

    • Query Compilation: A JDBC query is compiled when it's prepared.
    • Data Transfer: JDBC's ResultSet, PreparedStatement, and CallableStatement methods handle data transfer between applications and databases.
    • UDA Acronym: Universal Data Access
    • Connection establishment: The DriverManager class's getConnection() methods establish connections to databases.
    • JDBC Driver Types: JDBC technology provides: JDBC-ODBC bridge, NativeAPI, NetworkProtocol, and Thin drivers.
    • JDBC core package: java.sql is the core package.
    • RMI Methods: The Naming class has methods like rebind() to manage remote objects.
    • Executing SQL Queries: Using the executeQuery() method to retrieve data is very common.

    Module V

    • Cookies: Used for client-side maintaining session information. Cookies can be persistent or non-persistent (stateful or stateless).
    • Servlet Lifecycle Methods: init(), service(), destroy() are the primary lifecycle methods for a Servlet.

    Studying That Suits You

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

    Quiz Team

    Related Documents

    More Like This

    Untitled Quiz
    37 questions

    Untitled Quiz

    WellReceivedSquirrel7948 avatar
    WellReceivedSquirrel7948
    Untitled Quiz
    18 questions

    Untitled Quiz

    RighteousIguana avatar
    RighteousIguana
    Untitled Quiz
    50 questions

    Untitled Quiz

    JoyousSulfur avatar
    JoyousSulfur
    Untitled Quiz
    48 questions

    Untitled Quiz

    StraightforwardStatueOfLiberty avatar
    StraightforwardStatueOfLiberty
    Use Quizgecko on...
    Browser
    Browser