Advance Java Programming Prilim Exam

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By RSH_AJP
R
RSH_AJP
Community Contributor
Quizzes Created: 1 | Total Attempts: 942
Questions: 64 | Attempts: 944

SettingsSettingsSettings
Advance Java Programming Prilim Exam - Quiz


Questions and Answers
  • 1. 

    Which of these packages contains all the classes and methods required for even handling in Java?

    • A.

      Java.applet

    • B.

      java.awt

    • C.

      Java.event

    • D.

      java.awt.event

    Correct Answer
    D. java.awt.event
    Explanation
    The package "java.awt.event" contains all the classes and methods required for event handling in Java. This package provides classes and interfaces for handling events such as mouse clicks, keyboard inputs, and window events. It includes classes like ActionListener, MouseEvent, KeyEvent, and WindowListener, which are essential for implementing event-driven programming in Java. Therefore, "java.awt.event" is the correct answer as it specifically focuses on event handling in Java.

    Rate this question:

  • 2. 

    Which of these methods are used to register a mouse motion listener?

    • A.

      addMouse()

    • B.

      addMouseListener()

    • C.

      AddMouseMotionListner()

    • D.

      EventMouseMotionListener()

    Correct Answer
    C. AddMouseMotionListner()
    Explanation
    The correct answer is addMouseMotionListener(). This method is used to register a mouse motion listener in Java. It allows the program to detect and respond to mouse motion events, such as when the mouse is moved or dragged. By using this method, the program can add a listener that will be notified whenever there is a mouse motion event, and perform the desired actions accordingly.

    Rate this question:

  • 3. 

    What is a listener in context to event handling?

    • A.

      A listener is a variable that is notified when an event occurs.

    • B.

      A listener is a object that is notified when an event occurs.

    • C.

      A listener is a method that is notified when an event occurs.

    • D.

      None of the mentioned

    Correct Answer
    B. A listener is a object that is notified when an event occurs.
    Explanation
    A listener is an object that is notified when an event occurs. This means that when a specific event takes place, the listener object is informed and can perform certain actions or execute specific code in response to that event. The listener acts as a callback mechanism, allowing the program to respond dynamically to events as they happen.

    Rate this question:

  • 4. 

    Which of these methods can be used to determine the type of event? 

    • A.

      GetID()

    • B.

      GetSource()

    • C.

      GetEvent()

    • D.

      GetEventObject()

    Correct Answer
    A. GetID()
    Explanation
    The method getID() can be used to determine the type of event. This is because the ID of an event can provide information about the type or category of the event. By calling the getID() method, we can retrieve the ID associated with the event and use it to identify the type of event that occurred.

    Rate this question:

  • 5. 

    Which of these are integer constants defined in ActionEvent class? 

    • A.

      ALT_MASK

    • B.

      CTRL_MASK

    • C.

      SHIFT_MASK

    • D.

      All of the mentioned

    Correct Answer
    D. All of the mentioned
    Explanation
    All of the mentioned options (ALT_MASK, CTRL_MASK, SHIFT_MASK) are integer constants defined in the ActionEvent class. These constants represent modifier keys that can be used in combination with other keys to perform specific actions.

    Rate this question:

  • 6. 

    Which of these methods can be used to determine the type of adjustment event? 

    • A.

      getType()

    • B.

      GetEventType()

    • C.

      GetAdjustmentType()

    • D.

      GetEventObjectType()

    Correct Answer
    C. GetAdjustmentType()
    Explanation
    The method getAdjustmentType() can be used to determine the type of adjustment event. This method specifically retrieves the adjustment type associated with the event. The other methods getType(), getEventType(), and getEventObjectType() may retrieve different information about the event, but they do not specifically provide the adjustment type. Therefore, getAdjustmentType() is the correct method to use in order to determine the type of adjustment event.

    Rate this question:

  • 7. 

    Which of these constant value will change when the button at the end of scroll bar was clicked to increase its value? 

    • A.

      BLOCK_DECREMENT

    • B.

      BLOCK_INCREMENT

    • C.

      UNIT_DECREMENT

    • D.

      UNIT_INCREMENT

    Correct Answer
    D. UNIT_INCREMENT
    Explanation
    When the button at the end of the scroll bar is clicked to increase its value, the constant value that will change is UNIT_INCREMENT. This constant represents the amount by which the scroll bar value will increase when the button is clicked.

    Rate this question:

  • 8. 

    Which of these is superclass of all Adapter classes? 

    • A.

      Applet

    • B.

      Component

    • C.

      Event

    • D.

      InputEvent

    Correct Answer
    A. Applet
    Explanation
    The superclass of all Adapter classes is Component. The Applet class is a subclass of the Component class, so it is not the superclass. Event and InputEvent are not related to the Adapter classes.

    Rate this question:

  • 9. 

    JLabel(String s,Icon i,int align) the align argument can be

    • A.

      LEFT,RIGHT,CENTER,LEADING,TRAILING

    • B.

      RIGHT,LEFT,CENTER,TOP,BOTTOM

    • C.

      TOP,BOTTOM,CENTER

    • D.

      EAST,WEST,NORTH,SOUTH

    Correct Answer
    A. LEFT,RIGHT,CENTER,LEADING,TRAILING
    Explanation
    The align argument in the JLabel constructor can take values such as LEFT, RIGHT, CENTER, LEADING, and TRAILING. These values determine the alignment of the text and icon within the label.

    Rate this question:

  • 10. 

    • A.

      URL Class

    • B.

      URLConnection Class URLConnection Class URLConnection Class

    • C.

      Connection Class

    • D.

      ConnectionUrl Class

    Correct Answer
    B. URLConnection Class URLConnection Class URLConnection Class
  • 11. 

     which AWT component is used to create popup list of string items from which only one can be selected at a time. 

    • A.

      List

    • B.

      Choice

    • C.

      MenuBar

    • D.

      Scrollbar

    Correct Answer
    B. Choice
    Explanation
    The Choice component in AWT is used to create a popup list of string items from which only one can be selected at a time. It allows the user to select a single item from a list of options provided. This component is commonly used in forms or menus where the user needs to make a single selection from a predefined set of options.

    Rate this question:

  • 12. 

    Which is the passive control 

    • A.

      Checkbox

    • B.

      Scrollbar

    • C.

      Label

    • D.

      Button

    Correct Answer
    C. Label
    Explanation
    The correct answer is Label because a label is a passive control that is used to display text or information. It does not have any interactive functionality or control over user input. The other options, such as Checkbox, Scrollbar, and Button, are all active controls that allow the user to interact with them and perform specific actions.

    Rate this question:

  • 13. 

    Select appropriate code for the given output 

    • A.

      Code1

    • B.

      Code2

    • C.

      Code3

    • D.

      Code4

    Correct Answer
    A. Code1
  • 14. 

    Which method is used to display icon on a component?  

    • A.

      RollOverIcon(ImageIcon i)

    • B.

      SetIcon(ImageIcon i)

    • C.

      DisplayIcon(ImageIcon i)

    • D.

      RemoveIcon (ImageIcon i )

    Correct Answer
    B. SetIcon(ImageIcon i)
    Explanation
    The setIcon(ImageIcon i) method is used to display an icon on a component.

    Rate this question:

  • 15. 

    Identify the error in given program

    • A.

      Error in statement in which JScrollPane is created

    • B.

      Error in statement in which applet tag is declared

    • C.

      Error in statement in which JTable is created

    • D.

      None of the above

    Correct Answer
    C. Error in statement in which JTable is created
    Explanation
    The error in the given program is in the statement where the JTable is created.

    Rate this question:

  • 16. 

    What is output of the given code?

    • A.

      Only button OK is displayed

    • B.

      Only button Cancel is displayed.

    • C.

      Both button OK and button Cancel are displayed and button OK is displayed on the left side of button OK

    • D.

      Both button OK and button Cancel are displayed and button OK is displayed on the right side of button OK.

    Correct Answer
    B. Only button Cancel is displayed.
    Explanation
    The given code is expected to display only the button "Cancel". This can be inferred from the answer choice "Only button Cancel is displayed." The code likely contains a statement or condition that hides or removes the button "OK" from being displayed.

    Rate this question:

  • 17. 

    How many types of controls does AWT supports these controls are subclasses of component?

    • A.

      5

    • B.

      7

    • C.

      6

    • D.

      8

    Correct Answer
    B. 7
    Explanation
    AWT (Abstract Window Toolkit) supports 7 types of controls, which are subclasses of the Component class. These controls include Button, Checkbox, Choice, Label, List, TextArea, and TextField. Each control serves a different purpose and allows for user interaction in a graphical user interface.

    Rate this question:

  • 18. 

    Identify missing statements in given program

    • A.

      AdjustmentPerformed(AdjustmentEvent ae);

    • B.

      ItemStateChanged(ItemEvent ie);

    • C.

      ItemStateChanged(ActionEvent ie);

    • D.

      ActionPerformed(ActionEvent ae);

    Correct Answer
    B. ItemStateChanged(ItemEvent ie);
    Explanation
    The missing statement in the given program is actionPerformed(ActionEvent ae). This is because the other three methods (adjustmentPerformed, itemStateChanged with ItemEvent, and itemStateChanged with ActionEvent) are already declared and mentioned in the program. However, actionPerformed with ActionEvent is missing, indicating that it needs to be included in the program.

    Rate this question:

  • 19. 

    Identify components used in below output

    • A.

      Applet, Label TextField

    • B.

      Label, TextField, Button

    • C.

      Applet, Button TextField

    • D.

      Grid Layout, Label, Button

    Correct Answer
    B. Label, TextField, Button
    Explanation
    The correct answer is Label, TextField, Button. This is because the output includes a label, a text field, and a button. These components are commonly used in graphical user interfaces to display text, allow user input, and trigger actions respectively. The other options mentioned, such as Applet and Grid Layout, are not components but rather layout managers that can be used to arrange components in a specific way.

    Rate this question:

  • 20. 

    What is the purpose of Jtable?

    • A.

      JTable object displays rows and columns of data.

    • B.

      JTable object displays rows of data with header.

    • C.

      JTable object displays columns of data

    • D.

      JTable object displays data in Table form with header detail.

    Correct Answer
    A. JTable object displays rows and columns of data.
    Explanation
    The purpose of JTable is to display rows and columns of data.

    Rate this question:

  • 21. 

     identify the components used in given output:

    • A.

      TabbedPane, List, Applet

    • B.

      Panel, TabbedPane, List

    • C.

      Label, TabbedPane, CheckBox

    • D.

      Applet, TabbedPane, Panel

    Correct Answer
    B. Panel, TabbedPane, List
    Explanation
    The given output includes three components: Panel, TabbedPane, and List. These components are used to create a graphical user interface. The Panel component is a container that can hold other components, while the TabbedPane component allows for the creation of multiple tabs, each containing different content. The List component is used to display a list of items that can be selected by the user.

    Rate this question:

  • 22. 

    Select proper output?

    • A.

      Output1

    • B.

      Output2

    • C.

      Syntax Error In Program

    • D.

      Run Time Exception in Program

    Correct Answer
    A. Output1
    Explanation
    The correct answer is "output1" because it is one of the options provided and there is no additional information given to suggest that any of the other options would be the correct output.

    Rate this question:

  • 23. 

    What is Purpose of Jtree ?

    • A.

      Tree is used to display icon

    • B.

      Tree is used display button

    • C.

      Tree is used for Label

    • D.

      A tree is a component that presents a hierarchical view of elements

    Correct Answer
    D. A tree is a component that presents a hierarchical view of elements
    Explanation
    The purpose of a JTree is to present a hierarchical view of elements. It is used to display a structure where each element has a parent and can have one or more children. This allows for organizing and visualizing data in a tree-like structure, making it easier to navigate and understand relationships between different elements.

    Rate this question:

  • 24. 

    In event handling, A listener is a object that is notified when an event occurs.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    In event handling, a listener is an object that is notified when an event occurs. This means that when an event, such as a button click or a key press, happens, the listener object is informed and can perform some action in response to that event. This allows for the separation of event handling logic from the rest of the program, making it easier to manage and maintain. Therefore, the given answer "True" is correct.

    Rate this question:

  • 25. 

    ----------------------is a superclass for push button,checkboxes and radiobutton

    • A.

      Button

    • B.

      ScrollButton

    • C.

      AbstractButton

    • D.

      None

    Correct Answer
    C. AbstractButton
    Explanation
    AbstractButton is the correct answer because it is a superclass for push button, checkboxes, and radio buttons. This means that push button, checkboxes, and radio buttons inherit properties and behaviors from the AbstractButton class. The AbstractButton class provides common functionality for these types of buttons, such as handling user interactions and displaying visual states. Therefore, AbstractButton serves as a higher-level class that encapsulates the shared functionality for these specific types of buttons.

    Rate this question:

  • 26. 

    What is output of following program

    • A.

      The Internet address of the server

    • B.

      The Internet address of the client

    • C.

      The Internet address of the host

    • D.

      The Internet address of any other PC

    Correct Answer
    C. The Internet address of the host
    Explanation
    The output of the program will display the Internet address of the host.

    Rate this question:

  • 27. 

    The URLConnection class can be used to read and write data to the specified resource referred by the URL?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The URLConnection class in Java provides a way to establish a connection to a specified resource referred to by a URL. It allows reading and writing data to and from the resource. Therefore, the statement that the URLConnection class can be used to read and write data to the specified resource referred by the URL is true.

    Rate this question:

  • 28. 

    Which of these class is used to create servers that listen for either local or remote clientprograms?

    • A.

      httpServer

    • B.

      ServerSocket

    • C.

      Socket

    • D.

      HttpResponse

    Correct Answer
    B. ServerSocket
    Explanation
    The ServerSocket class is used to create servers that listen for either local or remote client programs. This class provides a mechanism for the server to listen for incoming client connections and accept them. Once a client connection is accepted, the server can then communicate with the client using input and output streams. Therefore, the ServerSocket class is the correct choice for creating servers that listen for client programs.

    Rate this question:

  • 29. 

    What is the output of this program?import java.net.*;class networking {public static void main(String[] args) throws Exception {URL obj = new URL("http://www.sanfoundry.com/javamcq");URLConnection obj1 = obj.openConnection();System.out.print(obj1.getContentType());} }

    • A.

      Html

    • B.

      Text

    • C.

      Text/html

    • D.

      Html/text

    Correct Answer
    C. Text/html
    Explanation
    The program uses the URL class to create a URL object with the specified URL "http://www.sanfoundry.com/javamcq". Then, it uses the openConnection() method of the URLConnection class to establish a connection to the URL. Finally, it uses the getContentType() method of the URLConnection class to retrieve the content type of the URL. In this case, the content type is "text/html", which is the correct answer.

    Rate this question:

  • 30. 

    Which of these exception is thrown by URL class’s constructors?

    • A.

      URLNotFound

    • B.

      MalformedURLException

    • C.

      URLSourceNotFound

    • D.

      URLNotFoundException

    Correct Answer
    B. MalformedURLException
    Explanation
    The correct answer is MalformedURLException. The URL class's constructors throw this exception when a malformed URL is encountered. This means that the URL provided is not in the correct format, such as missing the protocol or having invalid characters. The MalformedURLException allows the programmer to handle this specific error and take appropriate action, such as displaying an error message to the user or logging the exception for debugging purposes.

    Rate this question:

  • 31. 

    Which of these class is used to encapsulate IP address and DNS?

    • A.

      DatagramPacket

    • B.

      URL

    • C.

      InetAddress

    • D.

      ContentHandler

    Correct Answer
    C. InetAddress
    Explanation
    InetAddress is the correct answer because it is a class in Java that is used to encapsulate both IP addresses and DNS names. It provides methods to retrieve and manipulate IP addresses and perform DNS lookups. This class is commonly used in networking applications to identify and communicate with remote hosts using their IP addresses or DNS names.

    Rate this question:

  • 32. 

    What is the output of this program?
      import java.net.*;class networking {public static void main(String[] args) throws MalformedURLException {URL obj = new URL("http://www.sanfoundry.com/javamcq");System.out.print(obj.getPort());}}

      • A.

        1

      • B.

        0

      • C.

        -1

      • D.

        Garbage value

      Correct Answer
      C. -1
      Explanation
      The program creates a new URL object with the given URL "http://www.sanfoundry.com/javamcq". The getPort() method is then called on this object. Since the URL does not specify a port number, the getPort() method returns -1.

      Rate this question:

    1. 33. 

      Which of these class is necessary to implement datagrams?

      • A.

        DatagramPacket

      • B.

        DatagramSocket

      • C.

        Only DatagramSocket

      • D.

        Both A & B

      Correct Answer
      D. Both A & B
      Explanation
      Both the DatagramPacket and DatagramSocket classes are necessary to implement datagrams. The DatagramPacket class represents a datagram packet, which is essentially a container for a message that can be sent over a network. The DatagramSocket class, on the other hand, is responsible for creating a socket that can send and receive datagram packets. Therefore, to implement datagrams, both classes are required.

      Rate this question:

    2. 34. 

      Which of the method used to to get content type of this file?

      • A.

        ContentType()

      • B.

        ContentType()

      • C.

        GetContentType()

      • D.

        GetContentType()

      Correct Answer
      C. GetContentType()
      Explanation
      The correct answer is "getContentType()". This method is used to retrieve the content type of a file. It is likely a method provided by a programming language or framework that allows developers to access the metadata associated with a file, such as its content type.

      Rate this question:

    3. 35. 

      TCP,FTP,Telnet,SMTP,POP etc. are examples of ? 

      • A.

        Socket

      • B.

        IP Address

      • C.

        Protocol

      • D.

        MAC Address

      Correct Answer
      C. Protocol
      Explanation
      TCP, FTP, Telnet, SMTP, POP, etc. are examples of protocols. A protocol is a set of rules and guidelines that govern the communication between devices in a network. Each of these protocols serves a specific purpose. TCP (Transmission Control Protocol) is responsible for establishing a reliable connection between devices. FTP (File Transfer Protocol) is used for transferring files between computers. Telnet is a protocol that allows remote login to a computer. SMTP (Simple Mail Transfer Protocol) is used for sending emails, and POP (Post Office Protocol) is used for retrieving emails from a mail server.

      Rate this question:

    4. 36. 

      What is output of following program

      • A.

        Google

      • B.

        Http://www.google.com

      • C.

        Www.google.com

      • D.

        Google.com

      Correct Answer
      B. Http://www.google.com
      Explanation
      The given program outputs "http://www.google.com" because it is the only entry in the program that starts with "http://" and ends with ".com". The other entries do not meet this criteria, so they are not included in the output.

      Rate this question:

    5. 37. 

      What is the output of following program

      • A.

        IP address of www.google.com

      • B.

        All IP addresses of www.google.com

      • C.

        All internet protocols of www.google.com

      • D.

        All of the mentioned

      Correct Answer
      B. All IP addresses of www.google.com
      Explanation
      The correct answer is "All IP addresses of www.google.com". This is because the program is specifically designed to retrieve and display all the IP addresses associated with the domain name "www.google.com". The program does not mention anything about displaying the internet protocols or any other information, so those options are not applicable.

      Rate this question:

    6. 38. 

      What is the default length of the queue in following constructor of Serversocket? ServerSocket(int portno)

      • A.

        50

      • B.

        25

      • C.

        30

      • D.

        40

      Correct Answer
      A. 50
      Explanation
      The default length of the queue in the ServerSocket constructor with the parameter int portno is 50. This means that the ServerSocket can accept up to 50 incoming connections before it starts rejecting new connections.

      Rate this question:

    7. 39. 

      Which of these method of DatagramPacket is used to find the length of byte array?

      • A.

        Getnumber()

      • B.

        Length()

      • C.

        Length()

      • D.

        GetLength()

      Correct Answer
      D. GetLength()
      Explanation
      The method "getLength()" is used to find the length of the byte array in a DatagramPacket.

      Rate this question:

    8. 40. 

      Which methods are commonly used in ServerSocket class?

      • A.

        Public OutputStream getOutputStream()

      • B.

        Public synchronized void close()

      • C.

        Public Socket accept()

      • D.

        None of the above

      Correct Answer
      C. Public Socket accept()
      Explanation
      The correct answer is "public Socket accept()". This method is commonly used in the ServerSocket class to accept incoming client connections. It waits until a client connection is made and returns a Socket object representing that connection. This allows the server to communicate with the client using the returned Socket object. The other methods mentioned, getOutputStream() and close(), are not commonly used in the ServerSocket class.

      Rate this question:

    9. 41. 

      In given code ,fill the required methodsimport java.io.*;  import java.net.*;  public class InetDemo{  public static void main(String[] args){  try{  InetAddress ip=InetAddress.getByName("www.google.com");    System.out.println("Host Name: "+_________________);  System.out.println("IP Address: "+__________________);  }catch(Exception e){System.out.println(e);}  }  }   

      • A.

        Ip.getHostAddress()

      • B.

        Ip.getHostName()

      • C.

        Ip.getHostName(), ip.getHostAddress()

      • D.

        Ip.getHostAddress(),ip.getHostName()

      Correct Answer
      C. Ip.getHostName(), ip.getHostAddress()
      Explanation
      The correct answer is "ip.getHostName(), ip.getHostAddress()". This is because the code is trying to print the host name and IP address of "www.google.com". The method "ip.getHostName()" returns the host name, which is "www.google.com", and the method "ip.getHostAddress()" returns the IP address associated with that host, which is the IP address of Google's server. Therefore, using both methods will give us both the host name and IP address of "www.google.com".

      Rate this question:

    10. 42. 

      UDP you just send packets of data (datagrams) to some IP address on the network

      • A.

        True

      • B.

        False

      Correct Answer
      A. True
      Explanation
      The given statement is true. UDP (User Datagram Protocol) is a connectionless protocol in which data is sent in the form of packets called datagrams. These datagrams are sent to a specific IP address on the network without establishing a connection beforehand. Unlike TCP, UDP does not guarantee delivery or order of the packets, making it a faster but less reliable protocol for transmitting data.

      Rate this question:

    11. 43. 

      What is JDBC?

      • A.

        Java compiler

      • B.

        Java interpreter

      • C.

        Java API

      • D.

        Both A and B

      Correct Answer
      C. Java API
      Explanation
      JDBC stands for Java Database Connectivity, which is a Java API that allows Java programs to interact with databases. It provides a set of classes and methods for executing SQL statements, connecting to databases, and retrieving and manipulating data. The correct answer is "Java API" because JDBC is an API specifically designed for database connectivity in Java.

      Rate this question:

    12. 44. 

      select correct method of statement interface

      • A.

        Public ResultSet executeQuery(int s)

      • B.

        Public ResultSet executeQuery()throws SQLException

      • C.

        Public void executeQuery(String sql)throws SQLException

      • D.

        Public ResultSet executeQuery(String sql)throws SQLException

      Correct Answer
      D. Public ResultSet executeQuery(String sql)throws SQLException
      Explanation
      The correct method of the statement interface is "public ResultSet executeQuery(String sql) throws SQLException". This method takes a string parameter representing the SQL query and returns a ResultSet object. It also throws a SQLException if there is an error executing the query.

      Rate this question:

    13. 45. 

      Write a comment on following method Statement state = con.createStatement(); 

      • A.

        To empty the log

      • B.

        Creates statement object and returns it as the return value.

      • C.

        To prepare the statement

      • D.

        Creating url

      Correct Answer
      B. Creates statement object and returns it as the return value.
      Explanation
      The given method "Statement state = con.createStatement();" creates a new Statement object and assigns it to the variable "state". The method "createStatement()" is called on the "con" object, which is likely a connection to a database. This method is used to create a new Statement object that can be used to execute SQL queries on the database. The created Statement object is then returned as the return value of the method.

      Rate this question:

    14. 46. 

      To delete the records from database, use the following sequence of the part of coding: 

      • A.

        String b = ""delete from emp where ID=1""; PreparedStatement ps=con.prepareStatement(b);ps.executeUpdate();

      • B.

        String b = ""delete from emp where ID=1""; PreparedStatement ps=con.prepareStatement(b);ps.Update();

      • C.

        String b = ""delete from emp where ID=1""; PreparedStatement ps=con.prepareStatement(b) ;s.executeQuery();

      • D.

        String b = ""drop table from emp where ID=1""; PreparedStatement ps=con.prepareStatement(b); s.executeUpdate();

      Correct Answer
      A. String b = ""delete from emp where ID=1""; PreparedStatement ps=con.prepareStatement(b);ps.executeUpdate();
      Explanation
      The correct answer is the first option: String b = "delete from emp where ID=1"; PreparedStatement ps=con.prepareStatement(b);ps.executeUpdate(); This sequence of code uses the correct syntax to delete records from the "emp" table where the ID is equal to 1. The PreparedStatement is used to execute the SQL statement and the executeUpdate() method is used to perform the actual deletion.

      Rate this question:

    15. 47. 

      The JDBC-ODBC Bridge driver translates the JDBC API to the ODBC API and used with .......

      • A.

        JDBC driver

      • B.

        ODBC driver

      • C.

        Both A and B

      • D.

        None of the above

      Correct Answer
      B. ODBC driver
      Explanation
      The given correct answer is "ODBC driver". The JDBC-ODBC Bridge driver is used to translate the JDBC API (Application Programming Interface) to the ODBC (Open Database Connectivity) API. This allows Java applications to connect to databases using the ODBC driver. Therefore, the correct answer is the ODBC driver.

      Rate this question:

    16. 48. 

      The ............................. package contains classes that help in connecting to a database, sending SQL statements to the database, and processing the query results. 

      • A.

        Connection.sql

      • B.

        Db.sql

      • C.

        Javax.sql

      • D.

        Java.sql

      Correct Answer
      D. Java.sql
      Explanation
      The java.sql package contains classes that help in connecting to a database, sending SQL statements to the database, and processing the query results. This package provides the necessary tools and functionality for interacting with a database in Java applications. The classes in this package allow developers to establish database connections, execute SQL queries, retrieve and manipulate data, and handle database transactions. This package is essential for any Java application that needs to work with a database.

      Rate this question:

    17. 49. 

      Which of following statements loads the JDBC-ODBC driver?

      • A.

        Class.forName (sun.jdbc.odbc.JdbcOdbcDriver)

      • B.

        Class.forName (“sun.jdbc.odbc.JdbcOdbcDriver”)

      • C.

        Class.loadClass (“sun.jdbc.odbc.JdbcOdbcDriver”)

      • D.

        Class.loadClass (sun.jdbc.odbc.JdbcOdbcDriver)

      Correct Answer
      B. Class.forName (“sun.jdbc.odbc.JdbcOdbcDriver”)
      Explanation
      The correct answer is Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"). This statement is used to load the JDBC-ODBC driver by specifying the fully qualified name of the driver class as a string parameter. The Class.forName method is used to dynamically load the driver class at runtime, and in this case, it loads the JDBC-ODBC driver.

      Rate this question:

    18. 50. 

      The ................................ method executes a simple query and returns a single Result Set object.

      • A.

        ExecuteUpdate()

      • B.

        ExecuteQuery()

      • C.

        Execute()

      • D.

        Noexecute()

      Correct Answer
      B. ExecuteQuery()
      Explanation
      The executeQuery() method is the correct answer because it is used to execute a simple query and retrieve a single Result Set object. This method is typically used when you want to retrieve data from a database, such as selecting records from a table. It returns a Result Set object that contains the data fetched from the database, which can then be processed further in the code.

      Rate this question:

    Quiz Review Timeline +

    Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

    • Current Version
    • Mar 22, 2023
      Quiz Edited by
      ProProfs Editorial Team
    • Feb 23, 2017
      Quiz Created by
      RSH_AJP
    Back to Top Back to top
    Advertisement
    ×

    Wait!
    Here's an interesting quiz for you.

    We have other quizzes matching your interest.