Java MCQ β Home
Java Basic MCQ
β€ Java Hello World MCQ
β€ Find Java Keywords
β€ Java Identifier Quiz
β€ Java Data Types Quiz
β€ If-Else MCQ in Java-1
β€ If-Else MCQ in Java-2
Object class MCQ
β€ Object Class Quiz
β€ equals() Method Quiz
β€ Hashcode Value Quiz
β€ toString() Method Quiz
β€ Clone() Method Quiz
Multithreading MCQ
β€ Define a Thread-1
β€ Define a Thread-2
β€ Get/set ThreadName
β€ Thread State MCQ
β€ Thread Priority MCQ
β€ Yield(), join() & sleep()
β€ Synchronization MCQ
β€ Interthread Comms
β€ Deadlock, Daemon
Exception Handling
β€ Exception Handling-1
β€ Exception Handling-2
β€ Exception Handling-3
β€ Java try-catch MCQ-1
β€ Java try-catch MCQ-2
β€ Java try-catch MCQ-3
β€ Nested try-catch MCQ
β€ throw Keyword MCQ
β€ finally Block MCQ-1
β€ finally Block MCQ-2
β€ throws Keyword MCQ
Generics MCQ
β€ Java Generics Quiz-1
β€ Java Generics Quiz-2
β€ Java Generics Quiz-3
Collection Framework
β€ Collections Quiz-1
β€ Collections Quiz-2
β€ ArrayList MCQ-1
β€ ArrayList MCQ-2
β€ LinkedList MCQ
β€ Vector Stack MCQ
β€ Java Cursors MCQ
β€ Java TreeSet MCQ
β€ TreeSet & Comparator
Java Data Types Quiz | Find the correct answer for the below question | Recommended Reading:- Data types in Java, Float and double data type in Java
Q1) Java has how many primitive data types?
a) 7
b) 8
c) 9
c) None of these
View Answer
Answer:- b) 8Java primitive data types are:- byte, short, int, long, float, double, char, boolean.
Q2) Which of the following is false?
a) Primitive data type stores only one value at a time.
b) Reference data type can store multiple values at a time.
c) Reference data types can store different types of values.
d) None of these
View Answer
Answer:- d) None of theseAll statements are true.
Q3) In Java, the size of the char data type is?
a) 1 bit
2) 7 bits
3) 1 byte
4) 2 bytes
View Answer
Answer:- 4) 2 bytesJava characters are Unicode character set based and it ranges from 0 to 65535. Hence to store these values 2 bytes of memory is required.
Q4) The allowed values for the boolean data type are?
a) True
b) False
c) true
d) null
View Answer
Answer:- c) trueThe true and false are Java boolean literals and they are in lowercase.
Q5) Integer zero (0) is not the default value of which data type?
a) double
b) byte
c) short
d) long
View Answer
Answer:- a) doubleThe default value for double data type is 0.0, not 0.
Q6) Which of the following is valid?
a) byte b1 = 128;
b) byte b1 = βaβ;
c) byte b1 = 9.9;
d) byte b1 = false;
View Answer
Answer:- b) byte b1 = βaβ;Q7) In Java size of int data type is?
a) 2 bytes in 16-bit processor
b) 4 bytes in 16-bit/32-bit processor
c) 4 bytes in all systems
d) None of these
View Answer
Answer:- c) 4 bytes in all systemsJava is plateform independent programming language. The size of data types are fixed.
Q8) In Java by default every integer value is considered as which data type?
a) byte
b) int
c) long
d) double
View Answer
Answer:- b) intQ9) Which of the following is false?
a) double d = 97.5d;
b) double d = 97.5D;
c) double d = 97.5F;
d) None of these
View Answer
Answer:- d) None of theseTo represent double βdβ or βDβ prefix is optional. Double can store all its lesser range/precision value.
Q10) Which of the following is invalid?
a) float f1 = 10;
b) float f2 = βaβ;
c) float f3 = 9.9;
d) float f4 = 9.5F;
View Answer
Answer:- c) float f3 = 9.9;Q11) Which of the following is valid?
a) char ch1 = true;
b) char ch2 = 97;
c) char ch3 = 65536;
d) char ch4 = 97.0;
View Answer
Answer:- b) char ch2 = 97;Q12) The Java characters are based on?
a) Unicode character set
b) ASCII value
c) Both
d) None of these
View Answer
Answer:- a) Unicode character setQ13) The default value for all referenced data types?
a) 0
b) 0.0
c) null
d) false
View Answer
Answer:- c) nullQ14) Find the output of the below Java program?
class Test{
public static void main(String[] args) {
char ch1 = 97;
char ch2 = -98;
System.out.println(ch1+".."+ch2);
}
}
a) 97..98
b) a..b
c) a..-b
d) None of these
View Answer
Answer:- d) None of theseWe canβt store negative value to char data type, it gives compile time error.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!