-
What does this code displays in the console?
String relationshipStatus = "Single"; System.out.println(relationshipStatus);
-
What is the output of this code?
String color = "Blue"; //color = "Green"; System.out.println(color);
-
What is the return value of this round() method?
System.out.println(Math.round(12.49));
-
What is the return value of this length() method?
System.out.println("Hello World!".length());
-
How can we describe this code?
String color = "Blue";
-
What is a string in Java?
-
What is a variable in Java?
-
What’s the name of this variable?
String device = "Tablet";
-
What is the value of this variable?
String country = "Canada";
-
Use the name of the variable job to output its content.
String job = "Chef"; System.out.println("");
-
Name this variable website .
String "" = "dejavucode.com";
-
Update the value of the variable to Times Square, New York .
String eventLocation = "Central Park, New York"; ""
-
Update the variable by using the assignment operator .
String favoriteColor = "Red"; favoriteColor "" "Blue";
-
What is the output of this Java program?
String size = "Large"; size = "Medium"; size = "Small"; System.out.println(size);
-
Update the currentFilter by using the defaultFilter .
String defaultFilter = "none"; String currentFilter = "size"; ""
-
Define an integer variable.
"" customerSatisfactionScore = 4;
-
Complete this variable definition.
"" monthlyRevenue = 280000.0;
-
Complete this variable definition.
"" annualProfit = "$960000";
-
Why do we use comments ?
Java Exercises for Variables
If you’ve faced difficulties with these exercises, take a look at Variables Module on my Java course.
You can also share ‘Java Variables’ Exercises on your:
X (Twitter) – Telegram – Linkedin – Facebook – or on your favorite platform…