0
0
Javaprogramming~15 mins

Common string methods in Java - Interactive Code Practice

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

Complete the code to get the length of the string.

Java
String text = "Hello";
int length = text.[1]();
🎯 Drag options to blanks, or click blank then click option
Asize
BgetLength
Clength
Dcount
Attempts:
3 left
2fill in blank
medium

Complete the code to convert the string to uppercase letters.

Java
String word = "java";
String upper = word.[1]();
🎯 Drag options to blanks, or click blank then click option
AtoLowerCase
BtoUpperCase
Cuppercase
DmakeUpper
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to check if the string starts with "Hi".

Java
String greeting = "Hi there!";
boolean starts = greeting.[1]("Hi");
🎯 Drag options to blanks, or click blank then click option
AstartsWith
BbeginsWith
CstartWith
Dstarts
Attempts:
3 left
4fill in blank
hard

Fill both blanks to extract the substring "cat" from the word "concatenate".

Java
String word = "concatenate";
String part = word.[1](3, [2]);
🎯 Drag options to blanks, or click blank then click option
Asubstring
BsubString
C9
D6
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a new string with trimmed spaces and replaced spaces with underscores.

Java
String messy = "  hello world  ";
String clean = messy.[1]().[2](" ", [3]);
🎯 Drag options to blanks, or click blank then click option
Atrim
Breplace
C"_"
Dstrip
Attempts:
3 left