Java

MCQ questions and answers

  • 4.5/5.0
  • 1k Enrolled
  • All levels
  • Last updated 11/2023
  • English

Java MCQ (116)

1. ________ is known as user defined data type?
A Class
B Object
C int
D String

Answer: A

Description:  Class is known as Abstract Data Type(ADT).

2. ____________ is a unit of structural and behavioral modularity that contains a set of properties(or data) as well as the associate function.
A Class
B Method
C Object
D Abstraction

Answer: C

3. The wrapping up of data and methods into a single unit is known as____________.
A Abstraction
B Encapsulation
C Object
D None

Answer: B

4. ____________is the process of by which object of the one class can acquire the properties of another class.
A Polymorphism
B Virtual Function
C Inheritance
D Encapsulation

Answer: C

5. What is known as run time binding?
A Static binding
B Dynamic binding
C Compilation
D Execution

Answer: B

6. The inheritance provides the idea of____________.
A persitance
B portability
C resuability
D security

Answer: C

7. Java was developed at Sun Microsystem in 1991 by the team headed by____________.
A James Gosling
B Denish Ritchi
C Paul Allen
D none

Answer: A

8. Which is the first web browser developed in 1993?
A Hot Java
B Internet Explorer
C Mozilla
D Netscape Navigator

Answer: A

9. Java compiler convert java source code into ________
A MSIL code
B Native Code
C Binary Code
D Byte Code

Answer: D

10. Which keyword is not belong to java programming language?
A final
B virtual
C typedef
D B & C

Answer: D

11. __________ method is replaced by the destructor function in java?
A finalize()
B finally()
C destruct()
D Garbage Collector

Answer: A

12. Which are tiny programs that can be downloaded from the internet and can be run on java compatible web browser?
A Servlet
B JSP
C Applet
D Flash

Answer: C

13. Which java command convert source code into intermediate byte code?
A javap
B javac
C java
D javax

Answer: B

14. ____________ is a set of various tools used to develop and execute java programs .
A JDK
B JRE
C JVM
D JSL

Answer: A

15. ______ access specifier provides the access of variables and functions to the object of another class.
A private
B public
C protected
D default

Answer: B

16. Which java command enable us to convert the bytecode into a program description?
A javadoc
B javac
C javap
D javah

Answer: C

17. Which command is used to find an error in the program?
A javac
B java
C javadoc
D jdb

Answer: D

18. Which java package consists the date and time related functions?
A java.lang
B java.awt
C java.utility
D java.applet

Answer: C

19. In java, ________ is the 16 bit character set that defines characters which is found in all human language?
A ANSI
B Unicode
C Both
D None

Answer: B

20. What is the starting execution point of java program?
A main()
B class
C import
D classname

Answer: A

21. Which of the following is an invalid identifier?
A pg-hr
B void
C na60f
D t$ggl

Answer: B

22. Which of the following is an invalid arithmatic expression?
A 14/20/5
B (10/5)*3+6%2
C 64+/8.5
D (2+3)*9/3

Answer: C

23. Which of these is an example of compound assignment operator?
A a=5
B a=b=c=8
C a=b+c
D a+=b/c

Answer: D

24. Which operator is used to check whether an object belong to a specific class?
A instanceof
B new
C class
D typedef

Answer: A

25. A ____________ serve as a template that provides a layout common to all of its instance known as____________.
A class , inheritance
B object, class
C class, object
D none of these

Answer: C

26. ____________ is a fixed size in the memory and it is having element of a similar data type
A Pointer
B Structure
C Class
D Array

Answer: D

27. A____________is defined as the smallest unit of a program.
A class
B object
C identifiers
D token

Answer: D

28. Constant is also called as ____________.
A literals
B token
C identifier
D keyword

Answer: A

29. Conditional statements are also known as____________statement.
A selection
B nested
C both
D none

Answer: A

30. The____________ operator can be used as an alternative to the if-else statements.
A assignment
B conditional
C bitwise
D arithmatic

Answer: B

31. The control statement that execute a set of statements repeatedly based on a condition is known as an____________.
A iteration
B increment
C conditional
D none

Answer: A

32. The____________statements are used to transfer the control from one part of the program to another.
A break
B continue
C return
D jump

Answer: D

33. ____________ statement is used to terminate the current iteration of the loop.
A break
B continue
C return
D goto

Answer: B

34. Which statement is use to transfer control back to the caller and terminate the method in which it is present?
A continue
B goto
C return
D none

Answer: C

35. A ____________ has the same relation to ____________ which is a like basic data type with a variable.
A class , object
B object, class
C function, int
D none of these

Answer: A

36. Which of following operator is used for create a new object and allocate the memory space?
A dot operator
B new operator
C Instanceof operator
D none of these

Answer: B

37. Which is the correct syntax of an accessing the members of a class?
A class-member.class-object
B class-name.class-member
C class-object.class-name
D class-object.class-member

Answer: D

38. Which method is used to pass a different values to the instance variable of different object?
A parameterized
B constructor
C static method
D instanceof

Answer: A

39. There are too way by which an argument can be passed to the____________ and ____________.
A calling, called
B call by value & call by reference
C formal,parameter
D none

Answer: B

40. ___________is a positive integer value which indicates the position of an element is refered in an array.
A index
B subscript
C A and B both are same
D array value

Answer: C

41. Which of these array elements is referred by arr[3]?
A third
B second
C fourth
D fifth

Answer: C

42. String is always specified in____________.
A braces
B single quotes
C square bracket
D double quotes

Answer: D

43. Which method of string class is used to remove all the white space at the beginning and end of the string?
A trim()
B concat()
C subString()
D space()

Answer: A

44. What is the value of str1.length() function? Ex. str= “I love my country";
A 16
B 17
C 19
D 20

Answer: B

45. The class contain the method to store any number and any type of objects in a single unit called as _______
A Array
B Reflection
C Vector
D StringBuffer

Answer: C

46. The initial capacity of a default vector is____________.
A two
B one
C ten
D zero

Answer: C

47. Which class is inherited by the new class is called as____________.
A super class
B child class
C abstract class
D inherited class

Answer: A

48. A java subclass can be derived by using the ____________keyword.
A implements
B extends
C super
D class

Answer: B

49. Which type of inheritance is not implemented by java?
A Single level inheritance
B Multilevel inheritance
C Hierarchical inheritance
D Multiple inheritance

Answer: D

50. In which of the following inheritance is inherited by more than one subclass?
A Single level inheritance
B Multiple inheritance
C Hierarchical inheritance
D Multilevel inheritance

Answer: C

51. A member declared as____________ which can be assessed only within the class.
A private
B public
C protected
D default

Answer: A

52. Which keyword prevent a method in a super class from being overridden by its subclass?
A const
B final
C super
D abstract

Answer: B

53. Java enable us to specify that a method must be overridden in the subclass by using ____________ keyword.
A interface
B class
C abstract
D final

Answer: C

54. Which of the following classes can not be inherited?
A abstract class A
B class B
C final class C
D none of these

Answer: C

55. The variable in an interface are by default ____________and____________.
A static, private
B final, public
C private, public
D static, final

Answer: A

56. Which java API package is automatically imported?
A java.util
B java.awt
C java.lang
D java

Answer: C

57. The ____________statement is used to access the particular package in a program
A import
B using
C package
D namespace

Answer: A

58. Suppose there is a package PERSON which contains a public class Employee, then source file Employee.java will be stored in the sub-directory whose name is ____________.
A person
B employee
C package
D none

Answer: A

59. Applet uses the various method of ____________ and ____________ class.
A Applet, Awt
B Swing, Applet
C Frame, Applet
D Applet, Graphics

Answer: D

60. The execution of an applet begin from ____________ method.
A init()
B main()
C load()
D start()

Answer: A

61. ____________ method is used to remove the applet permanently from the memory.
A destroy()
B delete()
C garbabe collector
D stop()

Answer: A

62. What is the sequence of method invoked automatically when an applet is loaded till it is destroyed?
A init(), paint(), start(), stop(), destroy().
B start(), init(), paint(), stop(), destroy().
C start(), paint(), init(), destroy(), stop().
D init(), start(),paint(), stop(), destroy().

Answer: D

63. The ____________ method is used to display a string on an applet.
A paint()
B string()
C drawString()
D init()

Answer: C

64. Which tag is used to pass user defined parameter to an applet?
A INPUT
B VALUE
C PARAM
D None

Answer: C

65. The following tags are mandatory to display the applet.
A NAME , CODE, HEIGHT
B CODEBASE, HEIGHT, WIDTH
C CODE, HEIGHT, WIDTH
D CODE, NAME

Answer: C

66. Which method of the graphics class is used to draw image on an applet?
A drawString()
B draw()
C drawImage()
D paint()

Answer: C

67. Which of the following is a true statement?
A Java 1.0 modal has replace by Delegation Event Model
B The Delegation Event Model use event listeners to handle event
C Java 1.0 model is more efficient than Delegation Event Model
D The Delegation Event Model uses handleEvent() method to process event

Answer: B

68. The parent class in delegation event model is____________.
A Object
B EventObject
C Frame
D Container

Answer: B

69. Which event is generated by the click of button?
A KeypressEvent
B ButtonPressEvent
C ActionEvent
D ClickEvent

Answer: C

70. The ____________interface defines a method to handle the event related to keys in java program.
A actionPerformed
B keyPress
C keyListener
D actionListener

Answer: C

71. Which class implements an event listener interface and define all of its method with a blank body?
A Wrapper
B Interface
C Adapter
D Abstract

Answer: C

72. Which errors are difficult to detect?
A Compiler time error
B Runtime error
C Both
D None

Answer: B

73. An exception is caused by ____________.
A Compiler time error
B Logical error
C Runtime error
D None

Answer: C

74. Java exception handling mechanism mainly use five keywords.
A try, catch, finally, static, public.
B try, catch, public, exception, throw
C try, catch, finally,throw, throws
D try, catch, finally, exception, Synchronized

Answer: C

75. All the exception classes are inherited from the following built in classes which is known as______
A Exception
B Throwable
C Error
D Runtime Execution

Answer: B

76. A set of statements that may throw an exception in a program code is enclosed within the____________ block.
A try
B finally
C main()
D catch

Answer: A

77. Which exception is thrown when an illegal argument is used to invoke a method?
A IllegalArgumentException
B NullPointerException
C IOException
D NumberFormatException

Answer: A

78. Which of the following will not generate an error?
A A catch block without a try block.
B Presence of code between try and catch block.
C A try block with either a catch or finally block.
D A finally block without a try block.

Answer: C

79. The descriptive information about the exception occurred during program where execution can be retrieved using ____________method of the throwable class.
A printStackTrace()
B printTrace
C createOwnException
D desc()

Answer: A

80. A ____________ is a set of instructions that facilitates problem solving ability.
A algorithm
B software
C program
D none

Answer: C

81. Which java package is used to handle input output operations?
A java.lang
B java.util
C java.io
D java.awt

Answer: C

82. Stream classes can be categorized into two types namely.
A Byte stream classes, character stream classes
B File reader, File writer
C InputStream , OutputStream
D ByteRead, ByteWrite

Answer: A

83. Which method is used to clearing the content of buffer?
A destroy()
B empty()
C emptyBuffer()
D flush()

Answer: D

84. Which class is used to read input from the console input device?
A ReadLine()
B BufferReader()
C InputStreamReader
D ByteStreamReader

Answer: C

85. Which class is used to write the bytes to file?
A FileReader
B FileWriter
C OutputStream Classes
D fileOutputStream

Answer: B

86. What value does the read() method return when the end of file is reached?
A Zero
B One
C Null
D -1 (minus One)

Answer: D

87. Which class is used to read character from the file?
A ReadBuffer
B InputStreamReader
C FileReader()
D CharacterStream

Answer: C

88. DataInputStream class contains methods to read ____________.
A primitive datatype
B stream
C file
D none

Answer: A

89. Which class is allows the creation of a file that allows you to move the file pointer to a random position in the file prior to read or write operation?
A File
B FileReader and FileWriter class
C RandomAccess File
D Stream

Answer: C

90. Which method is used return a reference to the thread?
A Thread
B currentThread
C run
D none

Answer: B

91. The only method which is available in runnable interface is____________.
A start()
B run()
C sleep
D stop()

Answer: B

92. Which thread is known as a default thread which start executing immediately at the time of execution?
A main()
B init()
C thread
D none

Answer: A

93. The join() method takes the parameter in____________.
A second
B minuit
C millisecond
D none

Answer: C

94. Which keyword is used to synchronize a method or a block of statements?
A synchonized
B notify
C yield
D join

Answer: A

95. Which of the following is the default priority of a thread?
A Zero
B Five
C One
D Ten

Answer: B

96. The situation in which two or more thread are in a simultaneously waiting state for release of the resources which is held by one of the other waiting thread is called____________.
A deadlock
B spinlock
C mutual exclusion
D none

Answer: A

97. _______ methods are used in the inter-thread communication in Java.
A wait(), notify(), notifyall()
B wait(), join()
C notify(), join(), notifyall()
D none

Answer: A

98. _____ protocol is a connection oriented and reliable for the communication.
A UDP
B TCP
C IP
D SMTP

Answer: B

99. ______ protocol is a connection less protocol that manages the address part of each packet so that the package reaches the right destination?
A IP
B HTTP
C TCP
D UDP

Answer: A

100. The internet provides delivery services using a suit of the protocols are known as ____________.
A TCP
B IP
C TCP/IP
D UDP

Answer: C

101. Which of these protocol is/are used to implement the network layer?
A TCP
B IP
C UDP
D Both A and C

Answer: B

102. The port number _____ is reserved for http.
A 80
B 1024
C 1000
D 512

Answer: A

103. The IPv6 represent___ bit of address.
A 32
B 64
C 128
D 512

Answer: C

104. The combination of IP address and port no is known as ———-
A packet
B socket
C frame
D message

Answer: B

105. Which class is use to resolve the domain names to their IP address and vice versa?
A InetAddress
B serverSocket
C DatagramSocket
D HttpURLConnection

Answer: A

106. The DatagramSocket class is used to send or receive the ____________.
A responce
B message
C datagram packets
D packet

Answer: C

107. TCP server and client sockets are implemented using classes____________ and ____________ respectively.
A ServerSocket, Socket
B Datagram , Socket
C InetAddress, ServerSocket
D InetAddress, Socket

Answer: A

108. If any error occurred while creating the datagram socket which type of exception will raise?
A IOException
B packetNotFoundException
C SocketException
D none

Answer: C

109. _______ is the endpoint of a two way communication link between two programs running on the network?
A clientport
B port
C socket
D none

Answer: C

110. Which driver is use to access data through the driver using ODBC standard?
A Native API Partly Java
B JDBC-ODBC -Bridge
C Native protocol all java
D Net protocol all java client

Answer: C

111. _______ driver is a server based driver which uses network and middleware protocol for a communication with the server, further it translate to the DBMS specific function calls?
A Net protocol all java-client
B JDBC-ODBC
C Native-API partly
D Native protocal java

Answer: A

112. Which class is responsible for loading the driver specific classes?
A DriverManager
B registerDriver
C Connection
D resultSet

Answer: A

113. ____________ method allows you to specify the SQL query in which unknown values are replaced by question mark. Ex. “?"
A getConnection()
B preparedStatement
C createStatement()
D executeQuery

Answer: B

114. The ____________method provide the information about the vendor specific error whose meaning is defined by the driver vendor only.
A getErrorCode()
B SQLException()
C error()
D getNextException()

Answer: A

115. Which interface is use to establish a connection which the database?
A Statement
B getConnection
C Connection
D DriverManager

Answer: C

116. Which method is used to move the ResultSet cursor to a next row of the data?
A boolean next()
B boolean moveNext()
C boolean read()
D string getString(String column)
Answer: A

Video Lectures of C Language

Icon
Icon
Icon

Subscribe to our Newsletter for Newest Course Updates