In the name of ALLAH, the most beneficient, the most merciful

Web Design and Development (CS506)

Multiple Choice Questions (MCQs)

Objective Questions

  1. Java developed in ________

    1. 1990
    2. 1995
    3. 1997
    4. 2000
  2. If we remove static from main then program _______

    1. Program cannot compile
    2. Program will compile and work properly
    3. Run time errors
    4. Exception throws in main
  3. If we remove String array from main then program_______

    1. Program cannot compile
    2. Program will compile and work properly
    3. Run time errors
    4. Exception throws in main
  4. What will happen if static modifier is removed from the signature of main method?

    1. The program does not compile
    2. The program compiles and runs successfully
    3. The program compiles but does not run
    4. None of the given
  5. What will happen if main method is declared as private?

    1. The program does not compile
    2. The program throws an exception at run time
    3. The program compiles and runs successfully
    4. None of the given
  6. The toString () method returns a _________ representation of _______

    1. int, string
    2. string, int
    3. string, object
    4. object, string
  7. A variable declared as static in a class is a/an _________

    1. Instance variable
    2. Class variable
    3. Const variable
    4. Global variable
  8. Which of the following is used for inheritance in java?

    1. implements
    2. extends
    3. : (colon)
    4. inherit
  9. If a super class method is protected then overriding method _________

    1. must be protected
    2. must be public
    3. must be private
    4. may be either protected or public
  10. The collection API are defined in _______ package.

    1. java.io
    2. java.util
    3. java.awt
    4. java.sql
  11. HahMap takes key as a/an _________

    1. Object
    2. Array
    3. Primitive value
    4. Function
  12. A collection can store _________

    1. Homogenous objects
    2. Heterogeneous objects
    3. Objects as well as primitive values
    4. At most 100 objects
  13. When defining a method you must include a ___________ to declare any exception that might be thrown but is not caught in the method.

    1. try block
    2. finally block
    3. catch block
    4. throws-clause
  14. Aside from the Scanner class, which of the following classes can be used for text-file input?

    1. ObjectInputStream
    2. BufferedReader
    3. StringTokenizer
    4. None of the given
  15. Which of the following package needs to be import while handling files?

    1. java.util
    2. java.io
    3. java.awt
    4. javax.swing
  16. Which of the following stream is a Node stream?

    1. PrintWriter
    2. FileWriter
    3. BufferedReader
    4. All of the given.
  17. Which of the following syntax is used to attach an input stream to console?

    1. FileReader fr = new FileReader(“input.txt”);
    2. FileReader fr = new FileReader(FileDescriptor.in);
    3. FileReader fr = new FileReader(FileDescriptor);
    4. FileReader fr = new FileReader(console);
  18. Based on functionality, the streams can be categorized as ________

    1. Byte oriented stream and Node stream
    2. Filter stream and Character oriented stream
    3. Node stream and Filter stream
    4. Byte oriented stream and Character oriented stream
  19. Which of the following stream read/write data in the form of bytes?

    1. FileReader
    2. FileWriter
    3. PrintWriter
    4. FileInputStream
  20. Which of the following syntax attaches an output stream to console?

    1. FileWriter fw = new FileWriter(“output.txt”);
    2. FileWriter fw = new FileWriter(FileDescriptor.out);
    3. FileWriter fw = new FileWriter(FileDescriptor.in);
    4. FileWriter fw = new FileWriter(FileDescriptor);
  21. An instance of abstract class cannot be created.

    1. True
    2. False
  22. Which of the following is called "pure abstract class"?

    1. Concrete class
    2. Wrapper class
    3. Interface
    4. Abstract class with no abstract method
  23. The relationship between class and interface is called __________.

    1. Is a' relationship
    2. Has a' relationship
    3. Responds to' relationship
    4. None of the given
  24. JPanel and Applet use _________ as their default layout.

    1. Flow layout
    2. Border layout
    3. Grid layout
    4. GridBag layout
  25. Which of the following is a top level container?

    1. JPanel
    2. ToolBar
    3. ScrollPane
    4. Dialog
  26. Which of the following function will be used to register event handler with events generator (button)?

    1. addAction()
    2. addActionListener()
    3. addListener()
    4. None of the given
  27. If a class needs to handle events generated by button then which of the following interface a class needs to implement?

    1. ComponentListener
    2. KeyListener
    3. MouseListener
    4. ActionListener
  28. WindowListener interface contains __________ methods.

    1. Four
    2. Six
    3. Seven
    4. Eight
  29. Java defines _________ for the listener interfaces having more than one event handling methods.

    1. Wrapper classes
    2. Abstract classes
    3. Concrete classes
    4. Adapter classes
  30. Which of the following statement object is used to execute stored procedures?

    1. Statement
    2. PreparedStatement
    3. CallableStatement
    4. None of the given
  31. Which of the following statement object is used to execute simple SQL statement?

    1. Statement
    2. PreparedStatement
    3. CallableStatement
    4. None of the given
  32. previous() is a method of __________ object.

    1. Statement
    2. ResultSet
    3. ResultSetMetaData
    4. Connection
  33. Which of the following is NOT a method of ResultSet object?

    1. next()
    2. absolute(int)
    3. executeQuery(sql)
    4. updateRow()
  34. isReadOnly() is a method of _________ object.

    1. ResultSet
    2. ResultSetMetaData
    3. DataBaseMetaData
    4. Connection
  35. Which of the following syntax is used to get ResultSetMetaData object?

    1. None of the given
    2. ResultSetMetaData md = rs.getMetaData();
      // where rs is ResultSet object
    3. ResultSetMetaData md = st.getMetaData();
      // where st is Statement object
    4. ResultSet md = rs.getMetaData();
      // where rs is ResultSetMetaData object
  36. Which of the following object is passed as an argument to paintComponent() method?

    1. Image object
    2. JPanel object
    3. JFrame object
    4. Graphics object
  37. Which of the following methods are invoked by the AWT to support paint and repaint operations?

    1. paint( )
    2. repaint( )
    3. draw( )
    4. redraw( )