Thursday, May 7, 2026

Fifth Semester_JAVA_MCQ

 1. Which command is used for running Java programs?

  1. Java
  2. Javae
  3. Javac
  4. Javar

2. Which is the right syntax for creating object?

  1. Emp e
  2. Emp e=new Emp()
  3. Emp e=new Emp
  4. Emp e=Emp()

3. Which keyword is used for defining constants?

  1. const
  2. final
  3. define
  4. none of the above

4. Which access specifier allows members to be accessed only from the class and child classes?

  1. public
  2. private
  3. protected
  4. Default

5. Which of the following is checked exception?

  1. Arithmetic
  2. ArrayIndexOutOfBoundException
  3. FileNotFoundException
  4. SQLException

6. Which keywork is used for deriving an interface?

  1. extends
  2. derives
  3. implements
  4. inherit

7. Which class is character stream class?

  1. FileReader
  2. FileStream
  3. FileInputStream
  4. RandomFile

8. Which of the following is not container?

  1. Frame
  2. Panel
  3. Dialog
  4. TextField

9. Which interface needs to be implemented for handling button click events?

  1. ActionListener
  2. KeyListener
  3. ClickListener
  4. All of the above

10. Which JDBC driver is also called thin driver?

  1. Type 1
  2. Type 2
  3. Type 3
  4. Type 4

MCQ Final Paper 2079(i)

1. What is constructor?

  1. Same named function as class name
  2. Input function that initializes variables
  3. Function that is used to construct class in java 
  4. Garbage collector function

2. Why super keyword is used in inheritance?

  1. To represent the sub class and super class
  2. To access member of parent class
  3. To derive new.class
  4. To reference to member of derived classes

3. Why JDBC is there in java?

  1. To create web form
  2. To handle file
  3. To create database and execute queries
  4. To initialize object

4. How new class is derived from old class in java?

  1. class child extends parent{}
  2. class child implements parent{}
  3. class child: public parent{}
  4. class child as parent{}

5. Why static keyword is always there in front of main method in Java?

  1. Because static keyword should be used for void methods
  2. Because main method is public
  3. Because main method is built in method
  4. Because main method needs to be invoked before any object instantiation

6. Which of the following is not the valid loop statement in Java?

  1. while(true){}
  2. for(datatype var: array){}
  3. for(false){}
  4. do{}while(false);

7. What is late binding in Java?

  1. Association of methods and classes in runtime
  2. Association of object and methods in runtime
  3. Association of derived class and base class in runtime
  4. All of the above

8. Which of the following method is used to execute alter statement of SQL in Java program?

  1. createStatement()
  2. execute()
  3. executeUpdate()
  4. executeQuery()

9. Which of the following is not the string methods in Java? 

  1. trim()
  2. String()
  3. indexOf()
  4. gets()

10. Exception class in Java is derived from

  1. Throwable
  2. JavaLangException
  3. RuntimeException
  4. CompileTimeException

MCQ Final Paper 2077

1. What stands for JRE?

  1. Java Runtime Environment
  2. JVM Runtime Environment
  3. Java Robust Environment
  4. JVM Robust Environment

2. Which statement is used for terminating loops?

  1. break
  2. terminate
  3. final
  4. None of the above

3. Which statement is false about constructors?

  1. It does not have return type
  2. Its name is same as the name of class
  3. It cannot contain arguments
  4. It is invoked automatically

4. Which of the following is valid syntax of single inheritance?

  1. class extends class B
  2. class A: class B
  3. class A extends B
  4. class A: B

5. Which keyword is used for accessing members of parent class?

  1. parent
  2. base
  3. super
  4. sup

6. How many numbers of threads can be in ready state at a time?

  1. one
  2. two 
  3. four
  4. Many

7. Which of the following is byte stream class?

  1. FileReader
  2. FileWriter
  3. FileInputStream
  4. All of the above

8. Which package contains classes related to event handling?

  1. Java.awt
  2. Javax.swing
  3. Java.awt.event
  4. Javax.swing.event

9. What is name of method used for running Insert commands in JDBC?

  1. execute
  2. executeUpdate
  3. executeQuery
  4. executelnsert

10. Which of the following is default access specifier for interfaces?

  1. private
  2. public 
  3. protected
  4. default

MCQ Final Paper 2076

1. Which of these keywords is used by a class to use an interface defined previously?

  1. import
  2. Import
  3. implements
  4. Implements

2. In a java program, which of the following is true about package declaration?

  1. must precede
  2. must succeed
  3. may precede or succeed
  4. None

3. Which method is called internally by Thread start() method?

  1. execute()
  2. run()
  3. launch()
  4.  main()

4. Using which keyword we can access value of the instance variables and class variables inside the method of the class?

  1. super
  2. final
  3. this
  4. either super or this

5. Which component is used to compile, debug and execute java program?

  1. JVM
  2. JDK
  3. JIT
  4. JRE

6. Which of these keywords is not a part of exception handling?

  1. try
  2. finally
  3. thrown
  4. catch

7. Which of the following statements about abstract methods/classes in Java is true?

  1. An abstract class cannot be instantiated.
  2. Constructors can be abstract.
  3. A subclass of an abstract class must defined the abstract methods.
  4. Static methods may be declared abstract.

8. Which keyword is used to insert interface by another interface?

  1. public
  2. implements
  3. extends
  4. class

9. What type of event is generated when the user presses the enter key in a JTextField?

  1. ActionEvent
  2. ActionListener
  3. TextEvent
  4. ItemEvent

10. Which JDBC driver Type(s) is(are) the JDBC-ODBC bridge?

  1. Type 1
  2. Type 2
  3. Type 3
  4. Type 4


MOST PROBABLE

  1. Which feature of Java allows a method to have multiple forms?
    ✔ Polymorphism
    Inheritance
    Encapsulation
    Abstraction
  2. Which keyword is used to achieve inheritance in Java?
    ✔ extends
    implements
    inherits
    super
  3. Which of the following is not a primitive data type in Java?
    int
    float
    ✔ String
    char
  4. What is the default value of an int variable in Java class?
    ✔ 0
    null
    undefined
    1
  5. Which method is used to compare two strings in Java?
    compare()
    ==
    ✔ equals()
    match()
  6. Which memory area is used for object storage in Java?
    Stack
    ✔ Heap
    Register
    Cache
  7. Which keyword is used to prevent inheritance in Java?
    ✔ final
    static
    abstract
    private
  8. What is JVM in Java?
    Java Variable Machine
    ✔ Java Virtual Machine
    Java Verified Machine
    Java Visual Model
  9. Which collection allows duplicate elements?
    Set
    Map
    ✔ List
    Tree
  10. Which of the following is used for dynamic method dispatch?
    Method overloading
    ✔ Method overriding
    Constructor
    Static method
  11. Which keyword is used to handle exceptions?
    try
    throw
    ✔ catch
    all of the above
  12. What is the parent class of all classes in Java?
    String
    ✔ Object
    Class
    System
  13. Which operator is used for object comparison?
    =
    ==
    ✔ equals()
    :=
  14. Which of the following is not a feature of Java?
    Platform independent
    Object oriented
    ✔ Use of pointers
    Secure
  15. Which interface is used for sorting collections?
    ✔ Comparable
    Runnable
    Serializable
    Cloneable
  16. Which keyword is used to create object in Java?
    new ✔ new
    create
    object
    make
  17. Which of the following is a runtime exception?
    IOException
    SQLException
    ArithmeticException
    FileNotFoundException
  18. Which method is the entry point of Java program?
    start()
    run()
    main() ✔ main()
    init()
  19. Which keyword is used to refer current object?
    this ✔ this
    super
    self
    current
  20. Which of the following is used for thread creation?
    Runnable ✔ Runnable
    Stream
    Collection
    Map
  21. Which package is imported by default in Java?
    java.util
    java.io
    java.lang ✔ java.lang
    java.awt
  22. Which operator is used for logical AND in Java?
    &
    && ✔ &&
    ||
    !
  23. Which loop executes at least once?
    for
    while
    do-while ✔ do-while
    foreach
  24. Which keyword is used for exception throwing?
    throw ✔ throw
    catch
    try
    final
  25. Which of the following is not OOP concept?
    Inheritance
    Polymorphism
    Compilation ✔ Compilation
    Encapsulation
  26. Which class is used for file handling in Java?
    Scanner
    File ✔ File
    String
    System
  27. Which JDBC method is used to fetch data?
    executeUpdate()
    execute()
    executeQuery() ✔ executeQuery()
    runQuery()
  28. Which keyword prevents method overriding?
    final ✔ final
    static
    private
    abstract
  29. Which interface is used for input stream?
    OutputStream
    InputStream ✔ InputStream
    Reader
    Writer
  30. Which AWT component is used for text input?
    Label
    Button
    TextField ✔ TextField
    Checkbox
  31. Which of the following is used to handle mouse events?
    KeyListener
    MouseListener ✔ MouseListener
    ActionListener
    ItemListener
  32. Which collection does not allow duplicate elements?
    List
    ArrayList
    Set ✔ Set
    Vector
  33. Which keyword is used to inherit interface?
    extends ✔ extends
    implements
    inherit
    super
  34. Which is not a valid Java access modifier?
    public
    private
    protected
    internal ✔ internal
  35. Which class is parent of all exception classes?
    Object
    Throwable ✔ Throwable
    Error
    Runtime
  36. Which keyword is used to declare an interface?
    interface ✔ interface
    class
    implements
    abstract
  37. Which of the following is not a feature of Java?
    Object-oriented
    Platform independent
    Pointer arithmetic ✔ Pointer arithmetic
    Secure
  38. Which method is used to start a thread?
    run()
    execute()
    start() ✔ start()
    begin()
  39. Which class is used to read input from keyboard in Java?
    Scanner ✔ Scanner
    Buffer
    Input
    ReaderOnly
  40. Which keyword is used for memory allocation in Java?
    malloc
    alloc
    new ✔ new
    create
  41. Which statement is used to exit from loop?
    exit
    stop
    break ✔ break
    return
  42. Which of the following is a wrapper class?
    int
    float
    Integer ✔ Integer
    char
  43. Which keyword is used for multiple inheritance in Java?
    extends
    implements ✔ implements
    inherits
    super
  44. Which exception occurs when array index is wrong?
    NullPointerException
    IOException
    ArrayIndexOutOfBoundsException ✔ ArrayIndexOutOfBoundsException
    ArithmeticException
  45. Which method converts string to integer?
    parseInt() ✔ parseInt()
    toString()
    valueOf()
    convert()
  46. Which of the following is immutable in Java?
    Array
    String ✔ String
    Object
    List
  47. Which keyword is used to define constant variable?
    final ✔ final
    const
    static
    define
  48. Which method is used to print output in Java?
    print()
    System.out.println() ✔ System.out.println()
    echo()
    write()
  49. Which JDBC object is used to execute SQL query?
    Connection
    Statement ✔ Statement
    ResultSet
    Driver
  50. Which loop is best for fixed number of iterations?
    while
    do-while
    for ✔ for
    if
  51. Which class is used for writing to a file?
    FileReader
    FileWriter ✔ FileWriter
    FileInput
    FileOutput
  52. Which keyword is used for exception handling block?
    try ✔ try
    loop
    check
    error
  53. Which of the following is not a Java keyword?
    static
    void
    main ✔ main
    class
  54. Which method is used to compare two objects?
    equals() ✔ equals()
    compare()
    check()
    same()
  55. Which package contains AWT classes?
    java.io
    java.util
    java.awt ✔ java.awt
    java.net 

0 comments:

Post a Comment