0% found this document useful (0 votes)
1K views

Core Java MCQ Questions and Answers: Take Online Java MCQ Test To Test Your Knowledge

This document contains 30 multiple choice questions to test knowledge of core Java concepts. It covers topics like who developed Java, Java tools like JDB, return types of common methods, valid literals, array basics, and more. Answers are provided for self-checking understanding. The questions are from an online source for Java interview preparation and technical assessments.

Uploaded by

Mayank
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Core Java MCQ Questions and Answers: Take Online Java MCQ Test To Test Your Knowledge

This document contains 30 multiple choice questions to test knowledge of core Java concepts. It covers topics like who developed Java, Java tools like JDB, return types of common methods, valid literals, array basics, and more. Answers are provided for self-checking understanding. The questions are from an online source for Java interview preparation and technical assessments.

Uploaded by

Mayank
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

By OnlineInterviewQuestions.

com
Core Java MCQ Questions and Answers

Take Online Java MCQ Test to test your Knowledge


We have listed below the best Java MCQ Questions that check your basic knowledge of Java. this Java MCQ
Test contains 30 basic Java MCQ Questions. You have to select the right answer to every question. You can
download below the Java MCQ PDF for the best preparation for Java Interview.

Also, Read Best Java interview questions.

Q1. Java was originally developed by -

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

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

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

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

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

Q4. Which of the following option is a valid long literal?

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

Q5. 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

Q6. ______________ is the order of variables in Enum?

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

Q7. Which of the following method returns the elements of Enum class?

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

Q8. 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

Q9. BigDecimal is a part of___________ package?

A. java.math
B. java.lang
C. java.util
D. java.io
Q10. The LocalTime represents -

A. Time without Date


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

Q11. How to get UTC time using Java ?

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

Q12. Literals in java must be appended by -

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

Q13. 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

Q14. Arrays are _______ in Java?

A. primitive data type


B. objects
C. object references
D. None of These

Q15. _____ 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

Q16. 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

Q17. 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

Q18. Which of the following keywords is used to define packages in Java?

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

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

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

Q20. Which of the following method of class String is used to obtain length of String
object?

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

Q21. 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

Q22. Which data type value is returned by all transcendental math functions?

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

Q23. 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

Q24. 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’;

Q25. Which of the following method returns the elements of Enum class?

A. getEnum()
B. getEnums()
C. getEnumList()
D. getEnumConstants()
Q26. BigDecimal is a part of ............... package.

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

Q27. How to format date from one form to another?

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

Q28. Which of these is long data type literal?

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

Q29. 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

Q30. 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

Please Visit OnlineInterviewquestions.com to download more pdfs

You might also like