0
0
Javaprogramming~15 mins

Why strings are special in Java - Test Your Understanding

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a string variable named greeting.

Java
String greeting = [1];
🎯 Drag options to blanks, or click blank then click option
A"Hello"
BHello
C'Hello'
Dnew String
Attempts:
3 left
2fill in blank
medium

Complete the code to compare two strings for equality.

Java
if (str1.[1](str2)) {
    System.out.println("Strings are equal");
}
🎯 Drag options to blanks, or click blank then click option
AcompareTo
Bequals
C==
DequalsIgnoreCase
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to concatenate two strings correctly.

Java
String fullName = firstName [1] lastName;
🎯 Drag options to blanks, or click blank then click option
Aadd()
Bconcat()
C&
D+
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create a string and get its length.

Java
String word = [1];
int length = word.[2]();
🎯 Drag options to blanks, or click blank then click option
A"Java"
Blength
Clength()
Dsize()
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to check if a string starts with a letter and convert it to uppercase.

Java
if (text.[1]("A")) {
    String upper = text.[2]();
    System.out.println(upper.[3]());
}
🎯 Drag options to blanks, or click blank then click option
AstartsWith
BtoUpperCase
CtoLowerCase
Dtrim
Attempts:
3 left