-
Use numbers to define related variables.
class Main { public static void main(String[] args) { String securityQuestion1 = "What was the name of your first pet?"; String securityQuestion2 = "What is your favorite book?"; String securityQuestion"" = "In which city were you born?"; } }
-
What is the output of this Java code?
class Main { public static void main(String[] args) { String addressLine1 = "123 Main St."; String addressLine2 = "Apt. 4B"; String fullAddress = addressLine1 + addressLine2; System.out.println(fullAddress); } }
-
Complete the name of this variable by using camel case convention.
class Main { public static void main(String[] args) { String "" = "A4"; } }
-
What’s wrong with this variable?
class Main { public static void main(String[] args) { String product category = "electronics"; } }
-
Which variable name is more descriptive for holding a total budget value?
-
What’s wrong with this code?
class Main { public static void main(String[] args) { String budget = "$10000"; system.out.println(budget); } }
-
What’s wrong with this code?
class Main { public static void main(String[] args) { String url = "https://dejavucode.com"; System.out.println(URL); } }
-
What does case sensitivity mean in Java?
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…