Podcast
Questions and Answers
Which method is used to obtain the number of columns in a ResultSet?
Which method is used to obtain the number of columns in a ResultSet?
What is the correct return type of the method execute(String query)?
What is the correct return type of the method execute(String query)?
Which of the following statements is correct for executing a SQL query using Statement?
Which of the following statements is correct for executing a SQL query using Statement?
Which interface includes the commit() method?
Which interface includes the commit() method?
Signup and view all the answers
Which of the following SQL statement categories do INSERT, DELETE, and UPDATE belong to?
Which of the following SQL statement categories do INSERT, DELETE, and UPDATE belong to?
Signup and view all the answers
What will the code output when executed?
What will the code output when executed?
Signup and view all the answers
Which constants are defined by the AdjustmentEvent class?
Which constants are defined by the AdjustmentEvent class?
Signup and view all the answers
What notation is used to access a nested class in Java?
What notation is used to access a nested class in Java?
Signup and view all the answers
What type of mechanism does Inner class provide in Java?
What type of mechanism does Inner class provide in Java?
Signup and view all the answers
Which constants are defined by the ItemEvent class?
Which constants are defined by the ItemEvent class?
Signup and view all the answers
Non-static nested classes are commonly known as what?
Non-static nested classes are commonly known as what?
Signup and view all the answers
What is the main purpose of using inner classes?
What is the main purpose of using inner classes?
Signup and view all the answers
Can outer Java classes access the private members of inner classes?
Can outer Java classes access the private members of inner classes?
Signup and view all the answers
What is the result when using an adapter class in programming?
What is the result when using an adapter class in programming?
Signup and view all the answers
Which event does the method mouseClicked
specifically handle?
Which event does the method mouseClicked
specifically handle?
Signup and view all the answers
Which class serves as a superclass of ContainerEvent?
Which class serves as a superclass of ContainerEvent?
Signup and view all the answers
In an adapter class that contains 5 methods, how many methods are overridden typically?
In an adapter class that contains 5 methods, how many methods are overridden typically?
Signup and view all the answers
Which is the abstract adapter class for receiving keyboard focus events?
Which is the abstract adapter class for receiving keyboard focus events?
Signup and view all the answers
Adapter classes and interfaces are the same.
Adapter classes and interfaces are the same.
Signup and view all the answers
Adapter classes help save which of the following?
Adapter classes help save which of the following?
Signup and view all the answers
What is the primary error in the provided Java applet code?
What is the primary error in the provided Java applet code?
Signup and view all the answers
Which of the following is a legitimate return type for a controller action method?
Which of the following is a legitimate return type for a controller action method?
Signup and view all the answers
Which step is NOT part of the execution process in an MVC project?
Which step is NOT part of the execution process in an MVC project?
Signup and view all the answers
Which method is used to add a GUI component to a Frame object?
Which method is used to add a GUI component to a Frame object?
Signup and view all the answers
Which statement about a controller in MVC is TRUE?
Which statement about a controller in MVC is TRUE?
Signup and view all the answers
Which class is responsible for encapsulating an IP address and DNS in Java?
Which class is responsible for encapsulating an IP address and DNS in Java?
Signup and view all the answers
Which option is NOT one of the JFrame operations for window closure?
Which option is NOT one of the JFrame operations for window closure?
Signup and view all the answers
What is the return type of the getString() method?
What is the return type of the getString() method?
Signup and view all the answers
What is the correct SQL statement to delete an employee by ID in the provided code?
What is the correct SQL statement to delete an employee by ID in the provided code?
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?
Which class do the methods 'add(Component c)', 'setSize(int width, int height)', 'setLayout(LayoutManager m)', and 'setVisible(boolean)' belong to?
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?
Which container does not have a title bar or menu bar but can contain components like buttons and text fields?
Signup and view all the answers
What is used to create an object that displays a list of choices?
What is used to create an object that displays a list of choices?
Signup and view all the answers
Which of the following is used for storing partial data results and returning values for methods?
Which of the following is used for storing partial data results and returning values for methods?
Signup and view all the answers
Which class is associated with the processActionEvent( ) processing method?
Which class is associated with the processActionEvent( ) processing method?
Signup and view all the answers
Which feature does Swing support that differentiates it from AWT?
Which feature does Swing support that differentiates it from AWT?
Signup and view all the answers
What makes Swing components lightweight compared to AWT components?
What makes Swing components lightweight compared to AWT components?
Signup and view all the answers
What method is used to retrieve the local address of a server socket?
What method is used to retrieve the local address of a server socket?
Signup and view all the answers
Which method is used to bind a server socket to a specific address and port?
Which method is used to bind a server socket to a specific address and port?
Signup and view all the answers
The accept method is primarily used for which purpose?
The accept method is primarily used for which purpose?
Signup and view all the answers
Which class represents a socket that facilitates communication between a client and a server?
Which class represents a socket that facilitates communication between a client and a server?
Signup and view all the answers
What does the statement 'Socket s1 = new Socket(localhost, 1346);' signify?
What does the statement 'Socket s1 = new Socket(localhost, 1346);' signify?
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);'?
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);'?
Signup and view all the answers
Which of the following constructors is a correct way to instantiate a ServerSocket?
Which of the following constructors is a correct way to instantiate a ServerSocket?
Signup and view all the answers
What output is produced by 'System.out.println(ss.getLocalPort());' if ss is created with 'new ServerSocket(1349);'?
What output is produced by 'System.out.println(ss.getLocalPort());' if ss is created with 'new ServerSocket(1349);'?
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.
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!