Java Programming Quiz

15 Questions | Total Attempts: 3775

SettingsSettingsSettings
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 any 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.


Questions and Answers
  • 1. 
    All data members in an interface are by default
    • A. 

      Abstract and final

    • B. 

      Public and abstract

    • C. 

      Public, static, and final

    • D. 

      Default and abstract

  • 2. 
    Which of the following is correct for an abstract class? (Choose TWO)
    • A. 

      An abstract class is one that contains general-purpose methods.

    • B. 

      An abstract class is one that contains some defined methods and some undefined methods.

    • C. 

      An abstract class is one that contains only static methods.

    • D. 

      An abstract class can be declared final.

  • 3. 
    Which of the following statement gives the use of CLASSPATH?
    • A. 

      Holds the location of Core Java Class Library (Bootstrap classes)

    • B. 

      Holds the location of the Java Extension Library

    • C. 

      Holds the location of a User-Defined classes, packages, and JARs

    • D. 

      Holds the location of Java Software

  • 4. 
    Which of the following options give the valid argument types for the main() method? (Choose 2)
    • A. 

      String [][]args

    • B. 

      String args[]

    • C. 

      String[] args[]

    • D. 

      String[] args

  • 5. 
    Which of the following options give the valid package names? (Choose 3)
  • 6. 
    The term 'Java Platform' refers to
    • A. 

      Java Compiler (Javac)

    • B. 

      Java Runtime Environment (JRE)

    • C. 

      Java Database Connectivity (JDBC)

    • D. 

      Java Debugger

  • 7. 
    Which of the following methods are needed for loading a database driver in JDBC?
    • A. 

      Register driver method

    • B. 

      Class for name ()

    • C. 

      Register driver () method

    • D. 

      Get connection

  • 8. 
    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));
    • A. 

      Will show the first employee

    • B. 

      Compilation error

    • C. 

      Compiles but an error at runtime

    • D. 

      Compiles but no output

  • 9. 
    GetConnection() is method available in
    • A. 

      DriverManag

    • B. 

      Driver Interface

    • C. 

      ResultSet Interface

    • D. 

      Statement Interface

  • 10. 
    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)); }
    • A. 

      Will show only name

    • B. 

      Compilation error

    • C. 

      Will show the city

    • D. 

      Compiles but error at runtime

  • 11. 
    What is the default type of ResultSet in JDBC applications?
    • A. 

      Read-only

    • B. 

      Updatable, forward only.

    • C. 

      Read-only, scroll

    • D. 

      Updatable, scroll sensitive.

  • 12. 
    An application can connect to different databases at the same time.
    • A. 

      True

    • B. 

      False

  • 13. 
    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.
    • A. 

      Both are false

    • B. 

      Both are true

    • C. 

      Only A is false

    • D. 

      Only B is false

  • 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)); }
    • A. 

      Will show all rows of the first column

    • B. 

      Compilation error

    • C. 

      Compiles but an error at run time

    • D. 

      Compiles but runs without output

  • 15. 
    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?
    • A. 

      Statement

    • B. 

      Callable Statement

    • C. 

      Prepared statement

    • D. 

      Row set