0
0
Javaprogramming~15 mins

String creation 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 create a new String with the value "Hello".

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

Complete the code to create a String variable named name with the value "Alice".

Java
String name = [1];
🎯 Drag options to blanks, or click blank then click option
Anew String(Alice)
BAlice
C'Alice'
D"Alice"
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to correctly create a String with the text "Java".

Java
String lang = new String([1]);
🎯 Drag options to blanks, or click blank then click option
Ajava
B"Java"
C'Java'
DJava
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create a String variable called message with the value "Welcome".

Java
String [1] = new [2]("Welcome");
🎯 Drag options to blanks, or click blank then click option
Amessage
Bmsg
CString
Dstring
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a String variable named text with the value "Code" using the constructor.

Java
String [1] = new [2]([3]);
🎯 Drag options to blanks, or click blank then click option
Atext
BString
C"Code"
Dcode
Attempts:
3 left