0% found this document useful (0 votes)
5 views3 pages

Java MCQs Questions

The document contains multiple-choice questions (MCQs) focused on Java programming, specifically covering topics such as variable declarations, data types, operators, and their properties. It includes questions about valid variable names, default values, constant definitions, and the characteristics of primitive data types. The document serves as a quiz or study guide for individuals looking to test their knowledge of Java fundamentals.

Uploaded by

karthika ss
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Java MCQs Questions

The document contains multiple-choice questions (MCQs) focused on Java programming, specifically covering topics such as variable declarations, data types, operators, and their properties. It includes questions about valid variable names, default values, constant definitions, and the characteristics of primitive data types. The document serves as a quiz or study guide for individuals looking to test their knowledge of Java fundamentals.

Uploaded by

karthika ss
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java MCQ Questions - Variables, Data Types, and Operators

1. Which of the following is a valid variable declaration in Java?

a) int 1num

b) float my num

c) double salary

d) char = 'A'

2. What is the default value of a boolean variable in Java (for instance variables)?

a) true

b) false

c) 0

d) null

3. Which keyword is used to define a constant variable in Java?

a) finalize

b) const

c) final

d) static

4. Which of these is not a valid variable name in Java?

a) _value

b) value123

c) 123value

d) value_123

5. What is the size of int data type in Java?


a) 2 bytes

b) 4 bytes

c) 8 bytes

d) Depends on OS

6. Which of these is NOT a primitive data type in Java?

a) int

b) boolean

c) String

d) double

7. What is the range of byte in Java?

a) -128 to 127

b) 0 to 255

c) -32768 to 32767

d) -255 to 255

8. Which data type is used to store Unicode characters in Java?

a) String

b) char

c) Character

d) int

9. What is the output of this expression: 5 + 2 * 3?

a) 21

b) 15
c) 11

d) 7

10. Which of these is a logical operator in Java?

a) ==

b) =

c) &&

d) %

11. Which operator is used to compare two values in Java?

a) =

b) ==

c) !=

d) :=

12. What does the % operator do in Java?

a) Divides two numbers

b) Returns remainder

c) Converts to percentage

d) Rounds to nearest integer

13. Which of these is the correct syntax for incrementing a variable by 1?

a) x = x + 1;

b) x += 1;

c) x++;

d) All of the above

You might also like