Java SQL and Inner Classes Quiz
45 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

Which method is used to obtain the number of columns in a ResultSet?

  • getColumnCount() (correct)
  • getNumberOfColumn()
  • getColumns()
  • getMaxColumn()
  • What is the correct return type of the method execute(String query)?

  • boolean (correct)
  • ResultSet
  • int
  • void
  • Which of the following statements is correct for executing a SQL query using Statement?

  • ResultSet rs = stmt.selectQuery("SELECT ROLLNO, STUDNAME FROM STUDENT")
  • ResultSet rs = stmt.executeQuery("SELECT ROLLNO, STUDNAME FROM STUDENT") (correct)
  • ResultSet rs = stmt.executeSelect("SELECT ROLLNO, STUDNAME FROM STUDENT")
  • ResultSet rs = stmt.executeUpdate("SELECT ROLLNO, STUDNAME FROM STUDENT")
  • Which interface includes the commit() method?

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

    Which of the following SQL statement categories do INSERT, DELETE, and UPDATE belong to?

    <p>Data Manipulation Language</p> Signup and view all the answers

    What will the code output when executed?

    <p>data is 30</p> Signup and view all the answers

    Which constants are defined by the AdjustmentEvent class?

    <p>BLOCK_DECREMENT, BLOCK_INCREMENT, TRACK</p> Signup and view all the answers

    What notation is used to access a nested class in Java?

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

    What type of mechanism does Inner class provide in Java?

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

    Which constants are defined by the ItemEvent class?

    <p>DESELECTED, SELECTED</p> Signup and view all the answers

    Non-static nested classes are commonly known as what?

    <p>inner classes</p> Signup and view all the answers

    What is the main purpose of using inner classes?

    <p>all of these</p> Signup and view all the answers

    Can outer Java classes access the private members of inner classes?

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

    What is the result when using an adapter class in programming?

    <p>It can reduce boilerplate code significantly.</p> Signup and view all the answers

    Which event does the method mouseClicked specifically handle?

    <p>Mouse clicked</p> Signup and view all the answers

    Which class serves as a superclass of ContainerEvent?

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

    In an adapter class that contains 5 methods, how many methods are overridden typically?

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

    Which is the abstract adapter class for receiving keyboard focus events?

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

    Adapter classes and interfaces are the same.

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

    Adapter classes help save which of the following?

    <p>All of the above</p> Signup and view all the answers

    What is the primary error in the provided Java applet code?

    <p>The variable p1 cannot be found</p> Signup and view all the answers

    Which of the following is a legitimate return type for a controller action method?

    <p>All of these</p> Signup and view all the answers

    Which step is NOT part of the execution process in an MVC project?

    <p>Creating a database connection</p> Signup and view all the answers

    Which method is used to add a GUI component to a Frame object?

    <p>.add(Component c)</p> Signup and view all the answers

    Which statement about a controller in MVC is TRUE?

    <p>The controller executes an incoming request</p> Signup and view all the answers

    Which class is responsible for encapsulating an IP address and DNS in Java?

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

    Which option is NOT one of the JFrame operations for window closure?

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

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

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

    What is the correct SQL statement to delete an employee by ID in the provided code?

    <p>sql=&quot;delete from Employee where empid=&quot; + num</p> Signup and view all the answers

    Which class do the methods 'add(Component c)', 'setSize(int width, int height)', 'setLayout(LayoutManager m)', and 'setVisible(boolean)' belong to?

    <p>Component class</p> Signup and view all the answers

    Which container does not have a title bar or menu bar but can contain components like buttons and text fields?

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

    What is used to create an object that displays a list of choices?

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

    Which of the following is used for storing partial data results and returning values for methods?

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

    Which class is associated with the processActionEvent( ) processing method?

    <p>JButton, JList, JMenuItem</p> Signup and view all the answers

    Which feature does Swing support that differentiates it from AWT?

    <p>It follows MVC architecture.</p> Signup and view all the answers

    What makes Swing components lightweight compared to AWT components?

    <p>They do not rely on native GUI components.</p> Signup and view all the answers

    What method is used to retrieve the local address of a server socket?

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

    Which method is used to bind a server socket to a specific address and port?

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

    The accept method is primarily used for which purpose?

    <p>Accepting incoming client connections</p> Signup and view all the answers

    Which class represents a socket that facilitates communication between a client and a server?

    <p>java.net.Socket</p> Signup and view all the answers

    What does the statement 'Socket s1 = new Socket(localhost, 1346);' signify?

    <p>A client socket is created to connect with a specified hostname and port.</p> Signup and view all the answers

    What will the output be for the following code: 'int a = s1.getPort(); System.out.println(a);' if s1 is created with 'new Socket("localhost", 1234);'?

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

    Which of the following constructors is a correct way to instantiate a ServerSocket?

    <p>All of the above</p> Signup and view all the answers

    What output is produced by 'System.out.println(ss.getLocalPort());' if ss is created with 'new ServerSocket(1349);'?

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

    Signup and view all the answers

    Study Notes

    Adapter Classes

    • Adapter classes provide empty implementations of all methods in an event listener interface.
    • They are used to simplify the process of event handling in Java.
    • Required package for adapter classes is java.awt.event.

    Output of Code Examples

    • Different code examples produce different output, depending on the specific actions and methods involved in the code snippet.
    • The output of a code example depends on the implementation of the code's methods and actions.

    Additional Questions and Answers

    • Question 1: Classes in Java which have the key listener interface
    • Answer: KeyAdapter
    • Question 2: In Adapter class it is sufficient to include only the methods required for functionality
    • Answer: TRUE
    • Question 3: Adapter class makes programmers task easier.
    • Answer: True
    • Question 4: Which of these methods is defined in MouseMotionAdapter class?
    • Answer: mouseDragged()
    • Question 5: What are the different types of inner classes?
    • Answer: Local, Anonymous
    • Question 6: Which of these is a superclass of all Adapter classes?
    • Answer: Applet
    • Question 7: If an adapter class is inherited there is no need of implementing a listener interfaces
    • Answer: Always
    • Question 8: Adapter class can be also used for incorporating which property ?
    • Answer: All of the above (Inheritance, Polymorphism, Encapsulation)
    • Question 9: Is it sufficient in Adapter classes to include only the methods required?
    • Answer: Yes
    • Question 10: Whether adapter classes use the methods of event classes?
    • Answer: Yes
    • Question 11: Which of these methods is defined in MouseMotionAdapter class?
    • Answer: mouseDragged()
    • Question 12: Which of these is a superclass of all Adapter classes?
    • Answer: Applet
    • Question 13: Which is the abstract adapter class for receiving keyboard focus events?
    • Answer: FocusAdapter
    • Question 14: Adapter Class and interfaces are same?
    • Answer: False
    • Question 15: What are the different types of inner classes?
    • Answer: 1. Local inner classes and 2. Anonymous inner classes
    • Question 16: Adapter class saves?
    • Answer: All of the above (Time, Code, Space)
    • Question 17: Which of these methods is defined in MouseMotionAdapter class?
    • Answer: mouseDragged
    • Question 18: Which of these is a superclass of all Adapter classes?
    • Answer: Applet
    • Question 19: If an adapter class is inherited, is it required to implement listener interfaces?
    • Answer: No
    • Question 20: Which is the abstract adapter class for receiving keyboard focus events?
    • Answer: FocusAdapter
    • Question 21: Are Adapter Class and interfaces same?
    • Answer: No
    • Question 22: Which of these is a superclass of all Adapter classes?
    • Answer: Applet
    • Question 23: In Adapter class, is it sufficient to include only the required methods for the needed functionality?
    • Answer: Yes
    • Question 24: Adapter class makes programmers task easier
    • Answer: True
    • Question 25: What method in Java returns a reference to the component that was added to the container?
    • Answer:'getChild()' :
    • Question 26: A class that has an anonymous name is called as a _________ class in Java?
    • Answer: Anonymous
    • Question 27: What are the two ways to create a Java Anonymous inner class?
    • Answer: Class, Interface
    • Question 28: Which event is generated when a button is pressed?
    • Answer: ActionEvent
    • Question 29: if you compile a file containing inner classes, how many class files will be created?
    • Answer: 2
    • Question 30: When a component is added or removed from a container, which event is generated?
    • Answer: ContainerEvent
    • Question 31: Which of the following is the correct method for displaying a component in Java AWT's paint method?
    • Answer: drawString()
    • Question 32: Which class is the superclass in the inheritance hierarchy of all AWT event objects.
    • Answer: Event
    • Question 33: Which method returns the object that has generated an event?
    • Answer: getSource()
    • Question 34: What class adapts the methods of another class by giving a different name to the same methods?
    • Answer: Adapter Class
    • Question 35: If a class MyWindowAdapter extends WindowAdapter and implements the WindowListener interface, how is it registered?
    • Answer: this.addWindowListener(new MyWindowAdapter());
    • Question 36: What are the common methods of the CardLayout class?
    • Answer: next, previous, first
    • Question 37: What is the name for a class defined inside another class?
    • Answer: Inner Class
    • Question 38: What are the different types of inner classes?
    • Answer: Local and Anonymous inner classes
    • Question 39: Which class is used for handling mouse events?
    • Answer: MyMouseListener
    • Question 40: Which event is generated when a character is entered in a text field?
    • Answer: TextEvent
    • Question 41: Which constants are defined by MouseWheelEvent?
    • Answer: WHEEL_PAGE_SCROLL, WHEEL_TRACK_SCROLL, WHEEL_BLOCK_SCROLL, WHEEL_UNIT_SCROLL
    • Question 42: What is the return type of isTemporary() method?
    • Answer: boolean
    • Question 43: Which abstract class is a subclass of ComponentEvent and handles component input events?
    • Answer: InputEvent
    • Question 44: Can inner classes access all members of the outer class?
    • Answer: Yes
    • Question 45: What can be achieved by using inner classes?
    • Answer: code optimization
    • Question 46: Which method returns the object that generated an event in AWT/Swing ?
    • Answer: getsource()
    • Question 47: Which class is a class that is declared inside a class or interface in Java?
    • Answer: Inner class
    • Question 48: Which interfaces do you need to implement to handle mouse events ?
    • Answer: MouseListener and MouseMotionListener interfaces
    • Question 49: Which method in the Container class is used to return a reference to the component's container?
    • Answer: getParent()
    • Question 50: What is a class that doesn't have a name or is known by an implicit identifier known as in Java?
    • Answer: Anonymous class
    • Question 51: What are two ways to create an anonymous inner class in Java?
    • Answer: Using an interface or a class
    • Question 52: Which event occurs when a button is pressed?
    • Answer: ActionEvent
    • Question 53: How many class files are created when compiling a file with inner classes?
    • Answer: Two
    • Question 54: What event is generated when a component is added to or removed from a container?
    • Answer: ContainerEvent
    • Question 55: What is the protocol that web browsers use to transfer data?
    • Answer: HTTP

    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 on Java SQL execution, ResultSet methods, and inner classes. This quiz covers key concepts, methods, and event handling used in Java programming. Challenge yourself and see how well you understand these important topics!

    More Like This

    Use Quizgecko on...
    Browser
    Browser