Level 2 - Methods Flashcards

1
Q

Implement this method that takes any string and make it lowercase:

public static void calmDown(String s)
{

}

A

public static void calmDown(String s)
{
System.out.println( s.toLowerCase( ) );
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is output by the following code?
String s = “Beaver Cleaver”;
System.out.println(s.toUpperCase( ));

A

BEAVER CLEAVER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is output by the following code?
String s = “computer science”;
System.out.println(s.length( ));

A
16
//note - remember to count the spaces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Implement this method that would use the string s and print to the screen: win
String s = “twins”;

A

System.out.println(s.substring(1, 4) );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Write the signature for the static method that would make this line of code work:
double d = someMethod(“Joe”, 15.2);

A

public static double someMethod ( String s, double x)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly