

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


bigString.charAt( 3 ) ___________
bigString.charAt( bigString.length() โ 1 ) ___________
bigString.substring( 5, 11 ) ___________
bigString.indexOf( "java" ) ___________
Given the following definitions:
And the following variable definitions:
private Puppy puppy; private Kitty kitty; private Speakable speakable;
Indicate which are valid Java statements. Consider each statement as executed in the order it appears.
A) Valid Java statement โ No Compiler Error B) Invalid Java statement โ Compiler Error
puppy = new Puppy(); _______
kitty = new Kitty(); _______
puppy.speak(); _______
puppy.wag(); _______
puppy.sleep( 1000 ); _______
kitty.speak(); _______
kitty.wag(); _______
kitty.sleep( 2000 ); _______
speakable = puppy; _______
speakable.speak(); _______
speakable.wag(); _______
speakable = kitty; _______
speakable.speak(); _______
speakable.sleep( 3000 ); _______
puppy = kitty; _______
speakable = new Speakable(); _______
public interface Speakable { public String speak(); }
public class Puppy implements Speakable { private static final String PUPPY_SPEAK = "Bark";
public Puppy() { // ctor initialization here }
public String speak() { return PUPPY_SPEAK; }
public void wag() { // wag the tail } }
public class Kitty implements Speakable { private static final String KITTY_SPEAK = "Meow";
public Kitty() { // ctor initialization here }
public String speak() { return KITTY_SPEAK; }
public void sleep( int time ) { // kitty sleeps for time seconds } }
Value of count after loop terminates
Value of result after loop terminates