Q1. What is a Variable in Java?
s a memory location with a unique name.
r that stores the data values during Java program execution.
types of variables in Java: Local Variables, Instance Variables, and Static Variables.
a variable in a program, you need to perform 2 steps: Variable Declaration and Var
Q2. What are the steps in using a variable in a Java program?
A. To declare a variable, you need to assign it a valid value.
B. Variable Initialization comes before Variable Declaration.
C. You must specify the data type and give the variable a unique name.
D. Local, Instance, and Static are the three main types of Java variables.
Q3. What are the three types of variables in Java?
A. Integer Variables, Float Variables, and String Variables.
B. Local Variables, Global Variables, and Private Variables.
C. Local Variables, Instance Variables, and Static Variables.
D. Static Variables, Instance Variables, and Global Variables.
Q4. What is the purpose of Static Variables in Java?
A. Static variables are declared inside the body of a method.
B. Static variables should be initialized after instance variables.
C. Static variables are Object-specific and defined without the STATIC keyword.
D. Static variables are initialized only once, at the start of the program execution.
Q5. What is the primary purpose of Java Input?
A. To create objects in Java.
B. To handle exceptions in Java.
C. To perform arithmetic operations in Java.
D. To receive data or information into a Java program from external sources.
Q6. What is [Link]?
A. A class in Java used for taking user input.
B. A class in Java used for drawing graphics.
C. A class in Java used for connecting to databases.
D. A class in Java used for writing output to the console.
Q7. What do Java operators do?
A. Connect to databases.
B. Render graphics in Java programs.
C. Control the flow of execution in a program.
D. Perform operations on variables and values.
Q8. What is the purpose of Java Arithmetic Operators?
A. To assign values to variables.
B. To check whether an expression is true or false.
C. To check the relationship between two operands.
D. To perform arithmetic operations on variables and data.
Q9. What do Relational Operators in Java check?
A. The remainder after division.
B. The result of arithmetic operations.
C. Whether an expression is true or false.
D. The relationship between two operands.
Q10. What is the purpose of Java Logical Operators?
A. To assign values to variables.
B. To connect to external sources.
C. To perform arithmetic operations.
D. To check whether an expression is true or false.
Q11. What is the primary purpose of Java Input?
A. Creating objects in Java.
B. Rendering graphics in Java programs.
C. Performing arithmetic operations in Java.
D. Receiving data or information into a Java program from external sources.
Q12. What is [Link] used for?
Taking user input. C. Connecting to databases.
Handling file operations. D. Drawing graphics in Java program
____13. What do Java Operators do?
Connect to databases.
Render graphics in Java programs.
Control the flow of execution in a program.
Perform operations on variables and values.
Q13. What is the purpose of Java Arithmetic Operators?
A. To assign values to variables.
B. To check whether an expression is true or false.
C. To check the relationship between two operands.
D. To perform arithmetic operations on variables and data.
Q14. Which operator is used to get the remainder in Java?
A. / C. -
B. % D. *
______16. What do Relational Operators in Java check?
A. The remainder after division.
B. The result of arithmetic operations.
C. Whether an expression is true or false.
D. The relationship between two operands.
Q15. What is the importance of control statements in Java?
onnecting to external sources. C. Modeling real-world problems in code.
erforming arithmetic operations. D. Rendering graphics in Java progra
___18. How is the syntax of an if...else statement in Java?
(Boolean_expression) [ / Executes when the Boolean expression is true / ]
(Boolean_expression) ( / Executes when the Boolean expression is true / )
(Boolean_expression) { /* Executes when the Boolean expression is true / }
(Boolean_expression) : / Executes when the Boolean expression is true */
Q16. What is the simplest decision-making statement in Java?
f statement. C. Control statements.
f-else statement. D. Decision-making in real life.
______20. How are if statements executed in an if...else...if ladder in Java?
ndomly. C. From the bottom towards the top.
parallel. D. From the top towards the bottom.
__21. How would you use the [Link] class to read a line of text from the
tore it in a variable called userInput?
erInput = nextLine(); C. userInput = readString();
erInput = [Link](); D. userInput = getStringInput();
__22. You have two variables, num1 = 10 and num2 = 4. How would you use Java
ators to find the remainder when num1 is divided by num2?
ult = num1 % num2; C. result = num1 * num2;
ult = num1 / num2; D. result = num1 + num2;
__23. You have a variable totalScore and want to increase it by 10% in a Java progr
would you use Java operators to achieve this?
n a Java program, you have a variable temperatureInCelsius and want to co
hrenheit using the formula F = (C * 9/5) + 32. How would you implement
sion?
A. temperatureInFahrenheit = (temperatureInCelsius - 32) * 5/9;
B. temperatureInFahrenheit = temperatureInCelsius * 9/5 + 32;
C. temperatureInFahrenheit = temperatureInCelsius * 5/9 + 32;
D. temperatureInFahrenheit = temperatureInCelsius + 32 * 5/9;