AP String Test
Name _______________________________
String a = "Ethan Edwards";
String b = "Rick Blaine";
String c = "Susan Smith";
1. System.out.println(a.substring(4));
2. System.out.println(c.indexOf("S"));
3. System.out.println(a.indexOf(" "));
4. System.out.println(b.length()-b.indexOf(" "));
5. System.out.println(c.substring(3,4));
6. int n = a.indexOf(" ");
System.out.println(a.substring(0,n));
System.out.println(a.substring(n+1));
7.
int n2 = b.indexOf(" ");
for (int x = 0; x <= n2; x++)
System.out.println(b.substring(x,x+1));
8.
int n3 = c.indexOf(" ");
for (int x=n3; x >= 0; x--)
System.out.println(c.substring(x,x+1));
9.
for (int x=0; x < b.length();x++)
System.out.print(b.substring(x,x+1));
10. for (int x=0; x <= 4;x++)
System.out.println(a.substring(x));
11. Write a program that will take a name and print it out with names order
switched.
Enter a name Joe Smith
Smith Joe
12. Write a program that will let you enter your whole name and will then print out
your last name only.
13. Write a program that will let you enter a sentence and will then print out the
sentence without any vowels.
14. Write a program that will let you enter a full name and will then print out first
name in reverse order.
15. Write a program that will enter your name and will then print your last name
the number of letters that are in your first name. For example if your name was
Lhens Vilson the computer would print out Vilson 5 times (because there are 5
letters in Lhens).