Java Programming Practical
Exercises and Solutions//Verifed
and Approved//Latest Update 2025//
Guaranteed Pass
All Answers are in RED
What is a valid boolean declaration in Java?
boolean b3 = false;
Which of the following are valid float declarations in Java?
I. float f1 = -343; II. float f2 = 3.14; III. float f3 = 2001.0f; IV. float f4 = 2.81F; (Valid: III
and IV)
Identify three valid char declarations in Java.
1. char c3 = 0xbeef; 2. char c4 = \u0022; 3. char c6 = '\uface'; (Valid: 1, 3, 6)
Which list contains only Java programming language keywords?
A) class, if, void, long, int, continue
How many primitive data types are there in Java?
Eight
What is the formula to compute the minimum runway length needed for an
airplane to take off?
Length = v² / (2a)
What is the output of the program that computes Johan's monthly loan payment?
The program calculates the monthly payment based on the car price, deposit, loan
amount, and interest.
What are the four different ways to add 1 to an integer x in Java?
1. x = x + 1; 2. x++; 3. ++x; 4. x += 1;
Write a Java statement to declare variables sum and x as integers.
int sum, x;
How do you assign the value 1 to variable x in Java?
x = 1;
How do you assign the value 0 to variable sum in Java?
sum = 0;
How do you add variable x to variable sum and assign the result to sum?
sum = sum + x;
Write a Java statement to print the value of variable sum with a message.
System.out.println("The sum is: " + sum);
What is the purpose of the Scanner class in the runway length program?
It is used to read user input for speed and acceleration.
What is the significance of the 'f' suffix in float declarations?
It indicates that the number is a float literal.
What does the keyword 'class' signify in Java?
It is used to declare a class.
Exercises and Solutions//Verifed
and Approved//Latest Update 2025//
Guaranteed Pass
All Answers are in RED
What is a valid boolean declaration in Java?
boolean b3 = false;
Which of the following are valid float declarations in Java?
I. float f1 = -343; II. float f2 = 3.14; III. float f3 = 2001.0f; IV. float f4 = 2.81F; (Valid: III
and IV)
Identify three valid char declarations in Java.
1. char c3 = 0xbeef; 2. char c4 = \u0022; 3. char c6 = '\uface'; (Valid: 1, 3, 6)
Which list contains only Java programming language keywords?
A) class, if, void, long, int, continue
How many primitive data types are there in Java?
Eight
What is the formula to compute the minimum runway length needed for an
airplane to take off?
Length = v² / (2a)
What is the output of the program that computes Johan's monthly loan payment?
The program calculates the monthly payment based on the car price, deposit, loan
amount, and interest.
What are the four different ways to add 1 to an integer x in Java?
1. x = x + 1; 2. x++; 3. ++x; 4. x += 1;
Write a Java statement to declare variables sum and x as integers.
int sum, x;
How do you assign the value 1 to variable x in Java?
x = 1;
How do you assign the value 0 to variable sum in Java?
sum = 0;
How do you add variable x to variable sum and assign the result to sum?
sum = sum + x;
Write a Java statement to print the value of variable sum with a message.
System.out.println("The sum is: " + sum);
What is the purpose of the Scanner class in the runway length program?
It is used to read user input for speed and acceleration.
What is the significance of the 'f' suffix in float declarations?
It indicates that the number is a float literal.
What does the keyword 'class' signify in Java?
It is used to declare a class.