30th
Jan
Java MCQ

Java MCQ

  • Admin
  • 30th Jan, 2023
  • 925 Followers

Take Java MCQ Test to Test Your Knowledge

Practice here the top 50+ Java MCQ Questions, which are very popular & cover the latest and important topics of Java Programming Language. So practice these questions to check your final preparation for Java Exams, Interviews & Placement Drives. apart from this, you can also download Java MCQ PDF completely free.

Java MCQ Questions

1) Java was originally developed by -

  • A. Brendan Eich
  • B.James Gosling
  • C.Tim Berners-Lee
  • D.Guido van Rossum

2) Which of the following function is used to find and fix bugs in the Java programs?

  • A. JVM
  • B.JDK
  • C.JRE
  • D.JDB

3) _________is the return type of the hashCode() method in the Object class?

  • A. int
  • B.Object
  • C.void
  • D.long

4) Which of the following option is a valid long literal?

  • A. L990023
  • B.ABH8097
  • C.904423
  • D.0xnf029L

5) A single read/write operation performs _____ In character stream I/O.

  • A. Eight bytes read/write at a time
  • B.Two bytes read/write at a time
  • C.One byte read/write at a time
  • D.Five bytes read/ write at a time
Download Free : Java MCQ PDF

6) ______________ is the order of variables in Enum?

  • A. Descending order
  • B.Ascending order
  • C.Random order
  • D.Depends on the order

7) Which of the following method returns the elements of Enum class?

  • A. getEnumList()
  • B.getEnum()
  • C.getEnumConstants()
  • D.getEnums()

8) Which of the following is the limitation of toString() method of BigDecimal?

  • A. toString returns null
  • B.toString uses scientific notation
  • C.toString returns the number in expanded form
  • D.None of the above

9) BigDecimal is a part of___________ package?

  • A. java.math
  • B.java.lang
  • C.java.util
  • D.java.io

10) The LocalTime represents -

  • A. Time without Date
  • B.Date without time
  • C.Date and Time
  • D.Date and Time with timezone

11) How to get UTC time using Java?

  • A. Date.getUTC();
  • B.Time.getUTC();
  • C.Instant.now();
  • D.TimeZone.getUTC();

12) Literals in java must be appended by -

  • A. D
  • B.I
  • C.L
  • D.L & l

13) Which of the following is Truncation is Java?

  • A. Integer value assigned to floating type
  • B.Integer value assigned to floating type
  • C.Floating-point value assigned to an integer type
  • D.Floating-point value assigned to an Floating type

14) Arrays are _______ in Java?

  • A. primitive data type
  • B.objects
  • C.object references
  • D.None of These

15) _____ legally declare, construct and initialize an array

  • A. int [] myList = (5, 8, 2);
  • B.int myList [] = {4, 3, 7};
  • C.int myList [] [] = {4,9,7,0};
  • D.None of These

16) When you passed an array to a method, the method receives -

  • A. A copy of the array
  • B.The length of the array
  • C.A copy of the first element
  • D.The reference of the array

17) An attempt to add null key to a TreeMap will result in

  • A. Runtime - NullPointerException
  • B.Compile time Exception
  • C.Eror
  • D.None of These

18) Which of the following keywords is used to define packages in Java?

  • A. Pkg
  • B.pkg
  • C.package
  • D.Package

19) _________is the correct way of importing an entire package ‘pkg’.

  • A. Import pkg.
  • B.import pkg.
  • C.Import pkg.*
  • D.import pkg.*

20) Which of the following method of class String is used to obtain length of String object?

  • A. lengthof()
  • B.Sizeof()
  • C.length()
  • D.lengthof()

21) What is the range of short data type in Java?

  • A. -128 to 127
  • B.-32768 to 32767
  • C.-2147483648 to 2147483647
  • D.None of the Above

22) Which data type value is returned by all transcendental math functions?

  • A. int
  • B.float
  • C.long
  • D.double

23) Which of these coding types is used for data type characters in Java?

  • A. ASCII
  • B.UNICODE
  • C.ISO-LATIN-1
  • D.All of the Above

24) Which one is a valid declaration of a boolean?

  • A. boolean b1 = 1;
  • B.boolean b4 = ‘true’
  • C.boolean b3 = false;
  • D.boolean b2 = ‘false’;

25) Which of the following method returns the elements of Enum class?

  • A. getEnum()
  • B.getEnums()
  • C.getEnumList()
  • D.getEnumConstants()

26) BigDecimal is a part of ............... package.

  • A. java.io
  • B.java.util
  • C.java.math
  • D.java.lang

27) How to format date from one form to another?

  • A. DateFormat
  • B.DateConverter
  • C.SimpleFormat
  • D.SimpleDateFormat

28) Which of these is long data type literal?

  • A. 0x99fffL
  • B.0x99fffa
  • C.AbcDefG
  • D.None of the above

29) Which of these is an incorrect array declaration?

  • A. int arr[] = new int[5]
  • B.int arr[] = new int[5]
  • C.int arr[] = int [5] new
  • D.None of above

30) Modulus operator, %, can be applied to which of these?

  • A. Integers
  • B.Floating – point numbers
  • C.Both Integers and floating – point numbers
  • D.None of the above

31) Which of the following is the correct statement to return java?

  • A. "Java".toUpperCase()
  • B.toUpperCase("Java")
  • C.String.toUpperCase("Java")
  • D."Java".toUpperCase("Java")

32) Which of the following data type value is returned by all transcendental math functions?

  • A. int
  • B.long
  • C.float
  • D.double

33) A method is defined in a class as ...........

  • A. the return type of new method should exactly match that of overridden method
  • B.the argument list of new method should exactly match that of overridden method
  • C.Both A & B
  • D.None of the above

34) What will be the output of following code?

  • A. 0 0 0
  • B.null null null
  • C.NullPointerException
  • D.None of the above

35) Which of the following are the valid array declarations?

  • A. int arr[] = new int[];
  • B.float arr[10] = new fl
  • C.double []arr = new double[10];
  • D.None of the above

36) What will be the output of the following code?

  • A. Compiler Error
  • B.Constructor1
  • C.Constructor2
  • D.None of the Above

37) Which of the following are not wrapper classes?

  • A. String
  • B.Boolean
  • C.Integer
  • D.StringBuffer

38) Do Java Identifiers must start with a letter, dollar sign ($), or underscore (_)?

  • A. Yes
  • B.No

39) What is the result of attempting to compile and run the following program?

  • A. Runtime Exception
  • B.Compiletime error at line 3
  • C.Compiltime error at line 4,5
  • D.Compiletime error at lines 3,4,5

40) The length of an Array ‘abc’ can be found using .............

  • A. abc.size
  • B.abc.length
  • C.abc.size()
  • D.None of the above

41) ................ stops MultiThreading.

  • A. Yield()
  • B.Stop()
  • C.Synchronization
  • D.None of the above

42) What is the value of String s in the following code?

  • A. Gets version 1.8.16
  • B.Gets version 1.8
  • C.Searches “ JavaVersion”
  • D.Gets Properties of JavaVersion

43) What is the output of following code?

  • A. Prints 0 0 0 0
  • B.Prints 0 0 3 0
  • C.Prints 0 2 0 0
  • D.Compile erro

44) Which of the following is data structure which stores the key/value pairs in the List?

  • A. HashMap
  • B.HashTable
  • C.LinkedList
  • D.Both LinkedList & HashTable.

45) Collections are used to store, retrieve and manipulate data and to transmit data from one method to another.

  • A. True
  • B.False

46) What is the output of following code?

  • A. Sorts the instances in ascending order
  • B.Sorts test instances based on variable x
  • C.Sorts the instances in descending order.
  • D.None of the above

47) Which of the following are not legal identifiers in Java ?

  • A. String #baby;
  • B.Long long;
  • C.Short ~english;
  • D.All of the above

48) Identify the super class of all errors and exceptions in the Java language.

  • A. Error
  • B.Exception
  • C.Runnable
  • D.Throwable

49) Which of the following interface provides methods for retrieving data returned by an SQL statement?

  • A. Driver
  • B.ResultSet
  • C.Statement
  • D.All of the above

50) Which of the following performs iteration in either direction, modify the list during iteration, and obtain the iterator's current position in the list?

  • A. For
  • B.Foreach
  • C.Iterator
  • D.ListIterator

51) A class that is defined with a parameter of a type is called a ...........

  • A. Generic Class
  • B.Instance Class
  • C.Type class
  • D.Base Parameter Class

52) Which of the following method of Connection interface returns the instance of CallableStatement?

  • A. prepareCall()
  • B.CallMethod()
  • C.preparedCall()
  • D.connectioanCall()

53) List is used for collection of elements with duplicates.

  • A. True
  • B.False

54) Which of the followoing interface is used to order the objects of user-defined class in java?

  • A. Sort
  • B.Collections
  • C.Comparable
  • D.CompareTo

55) What will be the output of the folloiwng code?

  • A. The code runs fine
  • B.Runtime exception
  • C.compile time error at line 5
  • D.None of the above

56) When Subclass type refers to the object of Parent class, it is known as ..............

  • A. Object
  • B.Up casting
  • C.Down casting
  • D.Inheritance

57) What is the result of following code?

  • A. Compile Error
  • B.RunTime Error
  • C.Creates nodes of Linked List
  • D.Creates instance of Linked List

58) Which of the following keyword allows the main() method to be called, without needing to create an instance of the class?

  • A. static
  • B.abstract
  • C.synchronize
  • D.implements

59) Which option represents a string that can be modified?

  • A. String
  • B.String [ ];
  • C.String [ ] [ ]
  • D.StringBuffer

60) Polymorphism is the capability of a method to do different things based on the object that is acting upon it.

  • A. True
  • B.False

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.

Related MCQ/Quiz

01st
Mar
React JS MCQ
01st
Feb
Android MCQ
01st
Oct
MS Word MCQ
01st
Feb
Oracle MCQ
01st
Feb
NoSQL MCQ