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

Java Questions Without Answers

Uploaded by

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

Java Questions Without Answers

Uploaded by

hibabhs2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java Questions and Options (Without

Answers)
Which of the following are primitive data types in Java?

a) int

b) Integer

c) String

d) char

What is the default value of a boolean variable in Java?

a) true

b) false

c) null

d) undefined

Which keyword is used to declare a constant in Java?

a) const

b) static

c) final

d) constant

Which of the following is the correct syntax for declaring a method in Java?

a) method() {}

b) void method() {}

c) void method[] {}

d) function method() {}

Which of the following data types is not a primitive data type in Java?

a) int

b) float
c) char

d) String

What is the result of 10 / 3 in Java?

a) 3.0

b) 3

c) 3.333

d) 3.33

Which operator is used to compare two values in Java?

a) =

b) ==

c) !=

d) <=>

Which of the following is not a valid variable name in Java?

a) _myVar

b) 1stVariable

c) myVar

d) $value

What is the output of the following code: System.out.println(5 + 10 + 'A');

a) 15

b) 65

c) 55

d) Error

Which method is used to find the length of a string in Java?

a) length()

b) size()

c) getLength()
d) length

What is the purpose of the 'final' keyword in Java?

a) To define a variable that cannot be changed

b) To create a final method

c) To define an interface

d) To create an abstract class

You might also like