Java Programming Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Rahul Kumar
R
Rahul Kumar
Community Contributor
Quizzes Created: 3 | Total Attempts: 11,103
| Attempts: 4,782 | Questions: 15
Please wait...
Question 1 / 15
0 %
0/100
Score 0/100
1. An application can connect to different databases at the same time.

Explanation

An application can connect to different databases at the same time because modern applications are designed to be flexible and capable of handling multiple database connections simultaneously. This allows the application to retrieve and store data from different sources, enabling more complex and diverse functionality. Additionally, connecting to multiple databases can improve performance by distributing the workload across different systems.

Submit
Please wait...
About This Quiz
Java Programming Quiz - Quiz

An interesting Java programming quiz is here for you if you use Java programming or are learning this language. The quiz is not going to be easy in... see moreany way. The questions designed in the quiz are useful for testing your knowledge of various coding and allowing learning and practicing better with this quiz. Hope you give your best and score high marks on this test. All the very best to you in advance.
see less

2. The term 'Java Platform' refers to

Explanation

The term 'Java Platform' refers to Java Runtime Environment (JRE). The Java Platform is a software platform that includes the Java Virtual Machine (JVM), the Java class libraries, and the Java programming language. It provides the necessary tools and runtime environment for running Java applications and applets. The JRE consists of the JVM, class libraries, and other supporting files that are required to run Java programs. It does not include the Java Compiler (Javac), Java Database Connectivity (JDBC), or Java Debugger.

Submit
3. All data members in an interface are by default

Explanation

In Java, all data members in an interface are by default public, static, and final. Public means that the data members can be accessed from anywhere. Static means that the data members belong to the interface itself, rather than to any specific instance of the interface. Final means that the data members cannot be modified once they are initialized. These default modifiers ensure that the data members in an interface are accessible, shared, and cannot be changed.

Submit
4. Sam wants to develop a Student management system, which requires frequent insert operations about student details. In order to insert student records which statement interface will give good performance?

Explanation

A prepared statement would give good performance for frequent insert operations about student details in a student management system. Prepared statements are precompiled SQL statements that can be executed multiple times with different parameter values, reducing the overhead of parsing and optimizing the query each time it is executed. This can result in improved performance and efficiency when performing repetitive database operations like inserting student records.

Submit
5. GetConnection() is method available in

Explanation

The correct answer is DriverManager. The getConnection() method is available in the DriverManager class, which is used to establish a connection to a database. This class provides methods to manage the drivers and establish connections with different databases.

Submit
6. Which of the following methods are needed for loading a database driver in JDBC?

Explanation

The Register driver () method is needed for loading a database driver in JDBC. This method is used to register the driver class with the DriverManager. It is necessary to register the driver before establishing a connection to the database. The other methods mentioned in the options, such as Class for name () and Get connection, are not specifically related to loading the driver, but rather for establishing a connection and retrieving a connection from the DriverManager.

Submit
7. What is the default type of ResultSet in JDBC applications?

Explanation

The default type of ResultSet in JDBC applications is read-only. This means that the ResultSet object can only be used to retrieve data from the database and cannot be used to update or modify the data. This is the most common type of ResultSet used in most JDBC applications, as it provides a simple and efficient way to retrieve data from the database without the need for any updates or modifications.

Submit
8. Which of the following statement gives the use of CLASSPATH?

Explanation

The CLASSPATH is used to specify the location of user-defined classes, packages, and JAR files in Java. It allows the Java compiler and runtime environment to locate these files when they are needed for execution. The CLASSPATH variable can be set either through the command line or through environment variables. By specifying the correct location of user-defined classes, packages, and JAR files in the CLASSPATH, Java programs can access and utilize these files during runtime.

Submit
9. Which of the following options give the valid argument types for the main() method? (Choose
2)

Explanation

The main() method in Java is the entry point for a Java program. It takes an array of strings as its parameter, which is typically named "args". The options "String args[]" and "String[] args" both declare the parameter as an array of strings, which is a valid argument type for the main() method. Therefore, the correct answer is "String args[], String[] args".

Submit
10. A) When one uses a callable statement, in that the case only parameters are sent over the network not SQL query.

B) In preparing statement SQL, query will compile for the first time only.

Explanation

When using a callable statement, only the parameters are sent over the network, not the SQL query itself. This is because the SQL query is already compiled and stored on the database server. In the case of a prepared statement, the SQL query is compiled for the first time it is executed and then stored on the database server for future use. Therefore, both statements in the answer are true.

Submit
11. Which of the following options give the valid package names? (Choose 3)

Explanation

The correct answer is dollorpack.$pack.$$pack, $$.$$.$$, _score.pack.__pack. These package names follow the rules for valid package names in Java, which include starting with a letter or underscore, followed by letters, numbers, or underscores. The first option starts with a letter, followed by a dollar sign, and then another dollar sign. The second option consists of three dollar signs. The third option starts with an underscore, followed by letters and underscores. The other options do not follow the rules for valid package names.

Submit
12. Which of the following is correct for an abstract class? (Choose TWO)

Explanation

An abstract class is one that contains general-purpose methods. This means that the methods in the abstract class can be used for various purposes and can be implemented differently by different subclasses.

An abstract class is one that contains some defined methods and some undefined methods. This means that the abstract class can have some methods that are fully implemented and can be used directly, while other methods are declared without an implementation and must be implemented by the subclasses.

Note: The question is complete and readable.

Submit
13. Consider the following code & select the correct option for output.
String sql ="select empno,ename from emp";
PreparedStatement
pst=cn.prepareStatement(sql);
System.out.println(pst.toString());
ResultSet rs=pst.executeQuery();
System.out.println(rs.getString(1)+ "
"+rs.getString(2));

Explanation

The code will compile successfully but will throw an error at runtime because the ResultSet rs has not been moved to the first row before calling rs.getString(1) and rs.getString(2). Therefore, it will throw an exception indicating that the ResultSet cursor is before the first row.

Submit
14. Consider the code below & select the correct output from the options:
String sql ="select * from ?";
String table=" txyz ";
PreparedStatement
pst=cn.prepareStatement(sql);
pst.setString(1,table );
ResultSet rs=pst.executeQuery();
while(rs.next()){
System.out.println(rs.getString(1)); }

Explanation

The code is attempting to use a placeholder "?" in the SQL query and then set its value using the `setString()` method. However, placeholders can only be used for values, not for table or column names. Therefore, the code will compile without any errors, but it will throw an error at runtime when trying to execute the query.

Submit
15. Consider the following code & select the correct output.
String sql ="select rollno, name from student";
PreparedStatement
pst=cn.prepareStatement(sql);
System.out.println(pst.toString());
ResultSet rs=pst.executeQuery();
while(rs.next()){
System.out.println(rs.getString(3)); }

Explanation

The code compiles successfully because there are no syntax errors. However, it will result in an error at runtime because the query is selecting only the "rollno" and "name" columns from the "student" table, but in the while loop, it is trying to retrieve the value of the 3rd column using rs.getString(3). Since there are only 2 columns in the result set, it will throw an error at runtime.

Submit
View My Results

Quiz Review Timeline (Updated): Jul 3, 2023 +

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

  • Current Version
  • Jul 03, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 10, 2019
    Quiz Created by
    Rahul Kumar
Cancel
  • All
    All (15)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
An application can connect to different databases at the same time.
The term 'Java Platform' refers to
All data members in an interface are by default
Sam wants to develop a Student management system, which requires...
GetConnection() is method available in
Which of the following methods are needed for loading a database...
What is the default type of ResultSet in JDBC applications?
Which of the following statement gives the use of CLASSPATH?
Which of the following options give the valid argument types for the...
A) When one uses a callable statement, in that the case only...
Which of the following options give the valid package names? (Choose...
Which of the following is correct for an abstract class? (Choose TWO)
Consider the following code & select the correct option for...
Consider the code below & select the correct output from the...
Consider the following code & select the correct output....
Alert!

Advertisement