Level 2 - Methods Flashcards
Implement this method that takes any string and make it lowercase:
public static void calmDown(String s)
{
}
public static void calmDown(String s)
{
System.out.println( s.toLowerCase( ) );
}
What is output by the following code?
String s = “Beaver Cleaver”;
System.out.println(s.toUpperCase( ));
BEAVER CLEAVER
What is output by the following code?
String s = “computer science”;
System.out.println(s.length( ));
16 //note - remember to count the spaces
Implement this method that would use the string s and print to the screen: win
String s = “twins”;
System.out.println(s.substring(1, 4) );
Write the signature for the static method that would make this line of code work:
double d = someMethod(“Joe”, 15.2);
public static double someMethod ( String s, double x)