0% found this document useful (0 votes)
6 views

A-B-C

The document contains a series of multiple-choice questions and true/false statements related to Java programming concepts, including variable declaration, data types, loops, and operators. It also defines key terms such as algorithm, syntax, and type casting. The questions assess knowledge of Java syntax, control structures, and data handling.

Uploaded by

Antonette Paleng
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)
6 views

A-B-C

The document contains a series of multiple-choice questions and true/false statements related to Java programming concepts, including variable declaration, data types, loops, and operators. It also defines key terms such as algorithm, syntax, and type casting. The questions assess knowledge of Java syntax, control structures, and data handling.

Uploaded by

Antonette Paleng
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

Choose the best answer for each question.

1. What is the correct way to declare a variable in Java? a) int x = 10;


b) x = 10;
c) var x = 10;
d) integer x = 10;
2. Which keyword is used to define a class in Java?
a) define
b) class
c) object
d) structure
3. Which of the following is NOT a primitive data type in Java?
a) int
b) boolean
c) String
d) double
4. What does the switch statement evaluate?
a) boolean expressions
b) char, int, String, and enum values
c) float and double values
d) None of the above
5. Which operator is used for modulus operation in Java?
a) %
b) &
c) //
d) mod
6. How do you comment a single line in Java?
a) /* comment */
b) // comment
c) # comment
d) -- comment
7. What is the default value of an uninitialized boolean variable in Java?
a) true
b) false
c) null
d) 0
8. Which loop guarantees at least one execution of its body?
a) for loop
b) while loop
c) do-while loop
d) switch
9. What will System.out.println(5 + "5"); print?
a) 10
b) 55
c) Error
d) 5 + 5
10. What will happen if a for loop's condition is always true?
a) It will execute once
b) It will never execute
c) It will run indefinitely
d) It will throw an error
11. What is the result of 10 / 3 in Java?
a) 3.333
b) 3.0
c) 3
d) 10/3
12. Which of these operators is used for comparison?
a) =
b) ==
c) +=
d) ||
13. What does ++x do in Java?
a) Increments x before using its value
b) Increments x after using its value
c) Decreases x
d) Throws an error
14. What is the purpose of type casting?
a) To convert one data type to another
b) To compare data types
c) To store values permanently
d) To optimize memory
15. Which loop is best suited when the number of iterations is known?
a) while loop
b) do-while loop
c) for loop
d) switch
16. What does Math.pow(2,3) return?
a) 6
b) 8
c) 9
d) None of the above
17. What keyword is used to exit a loop?
a) continue
b) break
c) stop
d) exit
18. What is the output of System.out.println(10 > 5 && 5 > 10);?
a) true
b) false
c) Error
d) null
19. Which data type can store decimal values?
a) int
b) boolean
c) double
d) char
20. What is the correct syntax for a while loop?
a) while {condition} { }
b) while (condition) { }
c) do while (condition);
d) loop while (condition) { }

Write True if the statement is correct, otherwise write False.


1. The for loop in Java can have more than one initialization statement.
2. Java allows implicit type casting from double to int.
3. The switch statement can evaluate boolean values.
4. Java is a case-sensitive programming language.
5. The while loop checks its condition before executing the loop body.
6. The ++ operator can be used before or after a variable.
7. The break statement skips one iteration of a loop.
8. The do-while loop runs at least once, even if the condition is false.
9. int can store decimal values in Java.
10. The == operator is used to compare primitive values in Java.
Algorithm,
Syntax,
Comment,
Variable,
Data Type,
Type Casting,
Operator,
Boolean,
Loop,
Switch

1.A set of instructions designed to solve a


specific problem.
2.The correct structure and rules for writing Java
code.
3.A note in the code ignored by the compiler.
4.A named storage location in memory for
storing values.
5.Specifies the kind of value a variable can hold.
6.The process of converting one data type to
another.
7.A symbol used to perform mathematical or
logical operations.
8.A data type that represents true or false
values.
9.A control structure that repeats a block of code
multiple times.
10..A statement used to select one of many
possible execution paths based on a value.

You might also like