A Java Quiz

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 Myhemant72
M
Myhemant72
Community Contributor
Quizzes Created: 4 | Total Attempts: 8,983
Questions: 319 | Attempts: 1,636

SettingsSettingsSettings
A Java Quiz - Quiz

A Java Quiz


Questions and Answers
  • 1. 

    JTable has which of the following functions?

    • A.

      It stores data

    • B.

      It renders data

    • C.

      Both of the above

    • D.

      None of the above

    Correct Answer
    B. It renders data
    Explanation
    JTable has the function of rendering data. This means that it is capable of displaying data in a visually appealing and organized manner. It can format and present the data in various ways, such as through columns and rows, making it easier for users to view and understand the information. Additionally, JTable also allows for customization, allowing developers to modify the appearance and behavior of the table to suit their needs.

    Rate this question:

  • 2. 

    Statement.executeUpdate(); method is used for fetching the data from the database from netbeans?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The statement.executeUpdate() method is not used for fetching data from the database in NetBeans. It is used to execute SQL statements that modify the data in the database, such as INSERT, UPDATE, or DELETE statements. To fetch data from the database, the statement.executeQuery() method is used.

    Rate this question:

  • 3. 

    Statement.executeUpdate(); method is used for fetching the data from the database from netbeans?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The statement.executeUpdate() method is not used for fetching data from the database in NetBeans. This method is typically used for executing SQL statements that modify data in the database, such as INSERT, UPDATE, or DELETE statements. To fetch data from the database in NetBeans, other methods like statement.executeQuery() or PreparedStatement.executeQuery() are typically used.

    Rate this question:

  • 4. 

    JOptionPane.showInputDialog() will return?

    • A.

      Int

    • B.

      String

    • C.

      Double

    • D.

      Object

    Correct Answer
    B. String
    Explanation
    The JOptionPane.showInputDialog() method is used to display a dialog box that prompts the user for input. It returns a String value, which is the user's input. Therefore, the correct answer is String.

    Rate this question:

  • 5. 

    Which of the following needs to be imported for java jdbc connectivity JFrame project from netbeans?

    • A.

      Javax.sql.*;

    • B.

      Java.sql.*;

    • C.

      Javac.sql.*;

    • D.

      Java.sql;

    Correct Answer
    B. Java.sql.*;
    Explanation
    The correct answer is "java.sql.*;". This is because the java.sql package contains the necessary classes and interfaces for using JDBC (Java Database Connectivity) to connect to a database in a Java program.

    Rate this question:

  • 6. 

    You want to take the input of Hobbies from the user, ie Sports, Movies , Traveling etc which of the following controls would be the most suitable?

    • A.

      Radio Button

    • B.

      Check Box

    • C.

      Text Field

    • D.

      Combo box

    Correct Answer
    B. Check Box
    Explanation
    A check box would be the most suitable control for taking input of hobbies from the user. This is because a check box allows the user to select multiple options from a list, which is ideal for selecting multiple hobbies. A radio button, on the other hand, only allows the user to select one option, which would not be suitable for selecting multiple hobbies. A text field is used for entering free-form text, so it would not be appropriate for selecting hobbies from a predefined list. A combo box is a drop-down list that allows the user to select one option, so it would not be suitable for selecting multiple hobbies either.

    Rate this question:

  • 7. 

    Which of the following SQL objects will store the data retrieved through a Query?

    • A.

      Connection

    • B.

      Driver

    • C.

      Statement

    • D.

      ResultSet

    Correct Answer
    D. ResultSet
    Explanation
    The ResultSet object in SQL stores the data retrieved through a query. It is used to hold the result set of a query and allows for easy access and manipulation of the data. The ResultSet object can be used to iterate over the rows of the result set and retrieve the values of each column in a specific row.

    Rate this question:

  • 8. 

    Which of the following needs to be imported for java jdbc connectivity JFrame project from netbeans?

    • A.

      Javax.sql.*;

    • B.

      Java.sql.*;

    • C.

      Javac.sql.*;

    • D.

      Java.sql;

    Correct Answer
    B. Java.sql.*;
    Explanation
    The correct answer is "java.sql.*;". This is because the "java.sql" package contains classes and interfaces that are essential for JDBC (Java Database Connectivity) connectivity in a Java JFrame project. The other options, "javax.sql.*;", "javac.sql.*;", and "java.sql;", are incorrect as they either do not exist or do not provide the necessary classes for JDBC connectivity.

    Rate this question:

  • 9. 

    Class.forName() method is used for?

    • A.

      Firing the query

    • B.

      Getting the connection

    • C.

      Registering the Driver

    • D.

      None of the above

    Correct Answer
    C. Registering the Driver
    Explanation
    The Class.forName() method is used for registering the driver. In Java, before establishing a connection to a database, the driver needs to be registered. The Class.forName() method is used to dynamically load the driver class and register it with the DriverManager. This allows the driver to be available for establishing the connection to the database.

    Rate this question:

  • 10. 

    round and pow  are methods of?

    • A.

      Util package

    • B.

      Math package

    • C.

      Lang package

    • D.

      Net package

    Correct Answer
    B. Math package
    Explanation
    The methods "round" and "pow" are part of the Math package in Java. The Math package provides mathematical functions and operations, including rounding numbers and raising a number to a power.

    Rate this question:

  • 11. 

    Which keyword is used for implementing inheritance in java?

    • A.

      Implements

    • B.

      Extends

    • C.

      Inherits

    • D.

      Derives

    Correct Answer
    B. Extends
    Explanation
    The keyword "extends" is used for implementing inheritance in Java. Inheritance allows a class to inherit the properties and methods of another class, known as the superclass. The "extends" keyword is used to create a subclass that inherits the attributes and behaviors of the superclass. By using "extends", the subclass can access and use the methods and variables of the superclass, allowing for code reuse and creating a hierarchical relationship between classes.

    Rate this question:

  • 12. 

    Combination of two or more different kinds of inheritances is called?

    • A.

      Combination Inheritance

    • B.

      Hybrid Inheritance

    • C.

      Hierarchical Inheritance

    • D.

      Multiple Inheritance

    Correct Answer
    B. Hybrid Inheritance
    Explanation
    Hybrid inheritance refers to a combination of two or more different types of inheritances. This means that a class can inherit properties and methods from multiple base classes. It allows for greater flexibility and reusability of code, as it combines the benefits of different types of inheritances.

    Rate this question:

  • 13. 

    Calender is a static class?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    The statement is true because the Calendar class in Java is a static class. This means that it can be accessed directly without creating an instance of the class. The methods and fields in the Calendar class are also static, allowing them to be accessed without creating an object of the class.

    Rate this question:

  • 14. 

    Java is object oriented language because it supports classes and encapsulation?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Java is considered an object-oriented language because it supports the concept of classes and encapsulation. In Java, everything is treated as an object, and objects are instances of classes. Classes define the properties and behaviors of objects, and encapsulation allows for the bundling of data and methods within a class, providing data hiding and abstraction. These features are fundamental to object-oriented programming, making Java an object-oriented language.

    Rate this question:

  • 15. 

    Which of the following is used to add or delete from a JList?

    • A.

      DefaultListModel

    • B.

      ListModel

    • C.

      AddElement()

    • D.

      RemoveElement()

    Correct Answer
    A. DefaultListModel
    Explanation
    DefaultListModel is used to add or delete elements from a JList. It is a class that extends the AbstractListModel and provides methods such as addElement() and removeElement() to modify the contents of the JList. ListModel is an interface that provides methods to access the elements of a list but does not have methods to add or delete elements. Therefore, the correct answer is DefaultListModel.

    Rate this question:

  • 16. 

    for using date and calender which package should be imported?

    • A.

      Math

    • B.

      Util

    • C.

      Net

    • D.

      Applet

    Correct Answer
    B. Util
    Explanation
    To use date and calendar in a program, the "Util" package should be imported. This package contains classes and methods that provide functionality for working with dates and calendars. By importing the "Util" package, we can access and use the classes and methods related to date and calendar operations in our program.

    Rate this question:

  • 17. 

    The overloaded methods are distinguished by both the return type and signature of the method?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Overloaded methods are distinguished solely by the signature of the method, which includes the number, type, and order of the parameters. The return type of the method does not play a role in distinguishing overloaded methods. Therefore, the statement in the question is incorrect.

    Rate this question:

  • 18. 

    How many types of dialogs are supported by jOptionPane?

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      4

    Correct Answer
    D. 4
    Explanation
    jOptionPane supports four types of dialogs.

    Rate this question:

  • 19. 

    Each row of a JTable in java is added using?

    • A.

      String

    • B.

      Object

    • C.

      Component

    • D.

      Panel

    Correct Answer
    B. Object
    Explanation
    In Java, each row of a JTable is added using an Object. This is because JTable is a flexible component that can display data of any type. By using an Object, we can store and display different types of data in each row of the JTable.

    Rate this question:

  • 20. 

    Which of the following methods is used by DefaultTableModel class to add rows to table.

    • A.

      AddElement()

    • B.

      AddRow()

    • C.

      AddRow(Object newrow)

    • D.

      AddRows()

    Correct Answer
    C. AddRow(Object newrow)
    Explanation
    The DefaultTableModel class uses the addRow(Object newrow) method to add rows to a table. This method takes an object parameter representing the new row to be added to the table.

    Rate this question:

  • 21. 

    Arrange the events in the order they need to be carried out 1. Extract data from result set 2. import the sql package 3. Execute Query 4.Open a connection

    • A.

      1,3,2,4

    • B.

      4,3,2,1

    • C.

      3,2,4,1

    • D.

      2,4,3,1

    Correct Answer
    D. 2,4,3,1
    Explanation
    The correct order of events to be carried out is as follows:
    1. Import the sql package
    2. Open a connection
    3. Execute Query
    4. Extract data from result set.

    Rate this question:

  • 22. 

    The MySql service is available by default at which of the following ports?

    • A.

      6303

    • B.

      3606

    • C.

      3303

    • D.

      3306

    Correct Answer
    D. 3306
    Explanation
    The correct answer is 3306. This is the default port for the MySql service. Ports are used to establish communication between different services or applications. In the case of MySql, port 3306 is used to establish connections and transfer data between the MySql server and client applications.

    Rate this question:

  • 23. 

    The Statement.executeQuery() will return?

    • A.

      Int

    • B.

      String

    • C.

      Object

    • D.

      ResultSet

    Correct Answer
    D. ResultSet
    Explanation
    The Statement.executeQuery() method in Java returns a ResultSet object. This object represents a set of database query results, which can be used to retrieve and manipulate data from the database. The ResultSet object contains methods to navigate through the result set, retrieve data from the columns, and perform various operations on the data. Therefore, the correct answer is ResultSet.

    Rate this question:

  • 24. 

    Super keyword is used for which of the two purposes?

    • A.

      Refer to base class members with same name as in derived class in the derived class

    • B.

      Calling the base class destructors

    • C.

      To create new objects of the base class

    • D.

      Passing parameters to base class constructor

    Correct Answer(s)
    A. Refer to base class members with same name as in derived class in the derived class
    D. Passing parameters to base class constructor
    Explanation
    The super keyword is used in Java to refer to base class members with the same name as in the derived class. This allows the derived class to access and use the base class members without any ambiguity. Additionally, the super keyword is also used to pass parameters to the base class constructor when creating new objects of the base class.

    Rate this question:

  • 25. 

    The Statement.executeUpdate() will return?

    • A.

      Int

    • B.

      String

    • C.

      Object

    • D.

      ResultSet

    Correct Answer
    A. Int
    Explanation
    The Statement.executeUpdate() method in Java returns an integer value. This value represents the number of rows affected by the SQL statement that was executed. Therefore, the correct answer is "int".

    Rate this question:

  • 26. 

    The overloaded methods are distinguished by both the return type and signature of the method?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    The statement is false because overloaded methods are distinguished only by the signature of the method, not the return type. Overloaded methods can have the same return type but different parameters, or they can have different return types but the same parameters. The return type alone does not differentiate between overloaded methods.

    Rate this question:

  • 27. 

    How many types of dialogs are supported by jOptionPane?

    • A.

      1

    • B.

      2

    • C.

      3

    • D.

      4

    Correct Answer
    D. 4
    Explanation
    jOptionPane supports four types of dialogs. These dialogs are used to display messages or prompt the user for input. The four types include plain message dialog, information message dialog, warning message dialog, and error message dialog. Plain message dialog is used to display a simple message. Information message dialog is used to display an informational message. Warning message dialog is used to display a warning message. Error message dialog is used to display an error message.

    Rate this question:

  • 28. 

    JDBC can be used only from java?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    JDBC (Java Database Connectivity) is a Java API that allows Java programs to interact with databases. It provides a set of classes and interfaces that enable developers to connect to a database, execute SQL queries, and retrieve and manipulate data. Since JDBC is a Java API, it can only be used from Java programming language. Other programming languages may have their own APIs or libraries for interacting with databases. Therefore, the statement "JDBC can be used only from Java" is true.

    Rate this question:

  • 29. 

    Each row of a JTable in java is added using?

    • A.

      String

    • B.

      Object

    • C.

      Component

    • D.

      Panel

    Correct Answer
    B. Object
    Explanation
    In Java, each row of a JTable is added using an Object. This is because JTable is a flexible component that can display data of any type. By using an Object, we can store and display different types of data in each row of the JTable. This allows for a wide range of data to be displayed in a tabular format.

    Rate this question:

  • 30. 

    ODBC can be used from any front end?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    ODBC (Open Database Connectivity) is a standard programming interface that allows applications to access data in database management systems. It provides a consistent way for different front-end applications to communicate with various database systems. Therefore, ODBC can indeed be used from any front end, making the statement "True" correct.

    Rate this question:

  • 31. 

    JOptionPane.showConfirmDialog() will return which of the following?

    • A.

      Int

    • B.

      String

    • C.

      Object

    • D.

      ResultSet

    Correct Answer
    A. Int
    Explanation
    The JOptionPane.showConfirmDialog() method returns an integer value. This value represents the user's choice from the dialog box, which can be one of three options: YES_OPTION, NO_OPTION, or CANCEL_OPTION. Therefore, the correct answer is int.

    Rate this question:

  • 32. 

    Which of the following methods is used by DefaultTableModel class to add rows to table.

    • A.

      AddElement()

    • B.

      AddRow()

    • C.

      AddRow(Object newrow)

    • D.

      AddRows()

    Correct Answer
    C. AddRow(Object newrow)
    Explanation
    The DefaultTableModel class uses the addRow(Object newrow) method to add rows to a table. This method takes an object representing the new row as a parameter and adds it to the table.

    Rate this question:

  • 33. 

    Savepoints need to be named?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Savepoints in a database are used to mark a specific point in a transaction where it can be rolled back to in case of an error or failure. Naming savepoints allows for better management and identification of savepoints within a transaction. It provides a way to reference specific savepoints when performing rollback or commit operations. By naming savepoints, it becomes easier to track the sequence of savepoints and their purpose within a transaction, making it a good practice to name them.

    Rate this question:

  • 34. 

    By default autocommit is on?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    By default, the autocommit feature is turned on in most database management systems. This means that any changes made to the database are automatically saved and committed without the need for explicit commit statements. This can be convenient for simple operations where immediate persistence of data is desired. However, it can also lead to unintended consequences if not managed properly, such as accidental data modifications. Therefore, it is important to be aware of the autocommit setting and adjust it as needed for specific use cases.

    Rate this question:

  • 35. 

    Arrange the events in the order they need to be carried out 1. Extract data from result set 2. import the sql package 3. Execute Query 4.Open a connection

    • A.

      1,3,2,4

    • B.

      4,3,2,1

    • C.

      3,2,4,1

    • D.

      2,4,3,1

    Correct Answer
    D. 2,4,3,1
    Explanation
    The correct order of events is as follows:
    1. Import the sql package (2)
    2. Open a connection (4)
    3. Execute Query (3)
    4. Extract data from result set (1)

    Rate this question:

  • 36. 

    Till a user commits a transaction other users can not see the changed value during the progress of the transaction , which of the ACID properties does the above specify?

    • A.

      A

    • B.

      C

    • C.

      I

    • D.

      D

    Correct Answer
    C. I
    Explanation
    The given answer, "I", refers to the ACID property of Isolation. Isolation ensures that until a transaction is committed, the changes made by that transaction are not visible to other concurrent transactions. This property guarantees that each transaction is executed in isolation from other transactions, preventing interference and ensuring data consistency.

    Rate this question:

  • 37. 

    The MySql service is avialable by default at which of the following ports?

    • A.

      6303

    • B.

      3606

    • C.

      3303

    • D.

      3306

    Correct Answer
    D. 3306
    Explanation
    The correct answer is 3306. This port number is the default port for the MySQL service.

    Rate this question:

  • 38. 

    One transaction can have only one DML statement?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    False. One transaction can have multiple DML (Data Manipulation Language) statements. DML statements are used to modify, insert, or delete data in a database. In a transaction, multiple DML statements can be executed together as a single unit of work, ensuring that all changes are either committed or rolled back together. This allows for data consistency and integrity within the database.

    Rate this question:

  • 39. 

    Any DDL statement will automatically commit a tracnsatcion under progress?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    DDL (Data Definition Language) statements in SQL, such as CREATE, ALTER, and DROP, are automatically committed by default. This means that any changes made by these statements are immediately permanent and cannot be rolled back. Unlike DML (Data Manipulation Language) statements, which can be rolled back using the ROLLBACK command, DDL statements do not require an explicit COMMIT statement to make the changes permanent. Therefore, any DDL statement will automatically commit a transaction that is in progress.

    Rate this question:

  • 40. 

    Which of the following are the two advantages of Inheritence?

    • A.

      Code Reuse

    • B.

      Method contention

    • C.

      Models Real World

    • D.

      Low level data representation

    Correct Answer(s)
    A. Code Reuse
    C. Models Real World
    Explanation
    Inheritance allows for code reuse, as it allows a subclass to inherit the properties and methods of its superclass. This means that common functionality can be defined in a superclass and reused in multiple subclasses, reducing code duplication. Additionally, inheritance allows for modeling real-world relationships, as subclasses can inherit characteristics from their superclass that reflect real-world relationships between objects. This can make the code more intuitive and easier to understand.

    Rate this question:

  • 41. 

    Protected data members are accessible outside the class in which defined?

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    Protected data members are only accessible within the class in which they are defined and in the derived classes. They are not accessible outside of the class.

    Rate this question:

  • 42. 

    Which of the following two are determinants of the Signature of a class?

    • A.

      Return Type

    • B.

      Super Class

    • C.

      Datatype of parameters

    • D.

      Number of Parameters

    Correct Answer(s)
    C. Datatype of parameters
    D. Number of Parameters
    Explanation
    The datatype of parameters and the number of parameters are both determinants of the Signature of a class. The Signature of a class refers to the unique combination of the method's name, number of parameters, and the types of those parameters. Therefore, the datatype of parameters and the number of parameters are important factors in determining the signature of a class.

    Rate this question:

  • 43. 

    JOptionPane.showConfirmDialog() will return which of the following?

    • A.

      Int

    • B.

      String

    • C.

      Object

    • D.

      ResultSet

    Correct Answer
    A. Int
    Explanation
    The correct answer is int. The JOptionPane.showConfirmDialog() method returns an integer value that represents the user's choice in a confirmation dialog box. The returned value can be used to determine which button the user clicked, such as "Yes", "No", or "Cancel".

    Rate this question:

  • 44. 

    Class level variables are declared ?

    • A.

      Outside the class

    • B.

      In the constructor

    • C.

      In the beginning of the class definition

    • D.

      In any method of the class

    Correct Answer
    C. In the beginning of the class definition
    Explanation
    Class level variables are declared in the beginning of the class definition. This means that they are declared outside of any specific method or constructor in the class. By declaring variables at the class level, they become accessible to all methods within the class. This allows the variables to be shared and used throughout the class, rather than being limited to a specific method or constructor.

    Rate this question:

  • 45. 

    Savepoints need to be named?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Savepoints need to be named in order to be referenced later in the transaction. By assigning a name to a savepoint, it becomes possible to rollback to that specific savepoint if needed. This allows for more granular control over the transaction and enables the ability to undo specific portions of the transaction while preserving the changes made after the savepoint. Without naming savepoints, it would be difficult to identify and rollback to specific points in the transaction.

    Rate this question:

  • 46. 

    do -- while loop is exit controlled loop?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    A do-while loop is an exit-controlled loop because the condition is checked at the end of the loop. This means that the loop will always execute at least once before checking the condition. If the condition is true, the loop will continue to execute, otherwise, it will exit.

    Rate this question:

  • 47. 

    By default autocommit is on?

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    By default, autocommit is set to "on" in many database management systems. This means that each individual SQL statement is treated as a transaction and is automatically committed to the database once it is executed. This can be convenient for small or simple operations where you don't need to manually manage transactions. However, in more complex scenarios, it may be necessary to turn off autocommit and manually manage transactions to ensure data consistency and integrity.

    Rate this question:

  • 48. 

    Durability of a transaction means?

    • A.

      The longer time it takes to execute

    • B.

      The shorter time it takes to execute

    • C.

      Permanance of changes made

    • D.

      Transaction can be undone

    Correct Answer
    C. Permanance of changes made
    Explanation
    Durability of a transaction refers to the permanence of the changes made during the transaction. It ensures that once a transaction is committed, the changes made are permanent and will not be lost, even in the event of system failures or crashes. This is typically achieved by writing the changes to a persistent storage medium, such as a disk, so that they can be recovered and restored in case of any failure.

    Rate this question:

  • 49. 

    Till a user commits a transaction other users can not see the changed value during the progress of the transaction , which of the ACID properties does the above specify?

    • A.

      A

    • B.

      C

    • C.

      I

    • D.

      D

    Correct Answer
    C. I
    Explanation
    The given answer is "I" which stands for Isolation. This property of ACID ensures that until a transaction is committed, the changes made by that transaction are not visible to other users. This allows for concurrent transactions to be executed without interfering with each other and ensures data consistency.

    Rate this question:

  • 50. 

    You make payment for your air reservation through your mobile, this is an example of?

    • A.

      E-commerce

    • B.

      M-commerce

    • C.

      Brick and Mortar Model

    • D.

      Payment Gateway

    Correct Answer
    B. M-commerce
    Explanation
    Making a payment for an air reservation through a mobile device falls under the category of m-commerce, which stands for mobile commerce. M-commerce refers to any financial transaction or commercial activity conducted through a mobile device, such as a smartphone or tablet. In this scenario, the use of a mobile device to make a payment for an air reservation demonstrates the convenience and accessibility of m-commerce in modern-day transactions.

    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 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Oct 15, 2010
    Quiz Created by
    Myhemant72
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.