What is output by the code below?
String[] x;
x = new String[6];
System.out.println( x[2] );
What is output by the code below?
String[] x;
x = new String[7];
x[1] = "go";
x[4] = "up";
x[2] = "by";
System.out.println( x[1] );
What is output by the code below?
String[] x;
x = new String[7];
x[1] = "go";
x[4] = "up";
x[2] = "by";
System.out.println( x[0] );
What is output by the code below?
String[] x;
x = new String[7];
x[1] = "go";
x[4] = "up";
x[2] = x[4];
x[4] = null;
System.out.println( x[2] );
What is output by the code below?
String[] x;
x = new String[7];
x[1] = "go";
x[4] = "up";
x[2] = x[4];
x[4] = null;
System.out.println( x[2].length() );
Consider the following class definitions.
public class Cat
{
private String name:
private int age;
public Cat( String n, int a )
//implementation not shown
public String getName()
//implementation not shown
public int getAge()
//implementation not shown
//other methods not shown
}
//client code in another class
Cat[] bunch = new Cat[5];
System.out.println( bunch[0] );
Consider the following class definitions.
public class Cat
{
private String name:
private int age;
public Cat( String n, int a )
//implementation not shown
public String getName()
//implementation not shown
public int getAge()
//implementation not shown
//other methods not shown
}
//client code in another class
Cat[] bunch = new Cat[5];
System.out.println( bunch.length );
Consider the following class definitions.
public class Cat
{
private String name:
private int age;
public Cat( String n, int a )
//implementation not shown
public String getName()
//implementation not shown
public int getAge()
//implementation not shown
//other methods not shown
}
//client code in another class
Cat[] bunch = new Cat[5];
bunch[0] = new Cat("rocket", 8);
System.out.println( bunch[0].getAge() );
Consider the following class definitions.
public class Cat
{
private String name:
private int age;
public Cat( String n, int a )
//implementation not shown
public String getName()
//implementation not shown
public int getAge()
//implementation not shown
//other methods not shown
}
//client code in another class
Cat[] bunch = new Cat[5];
bunch[0] = new Cat("rocket", 8);
bunch[3] = new Cat("sam", 15);
bunch[4] = new Cat("ben", 12);
System.out.println( bunch[3].getAge() );
Consider the following class definitions.
public class Cat
{
private String name:
private int age;
public Cat( String n, int a )
//implementation not shown
public String getName()
//implementation not shown
public int getAge()
//implementation not shown
//other methods not shown
}
//client code in another class
Cat[] bunch = new Cat[5];
bunch[0] = new Cat("rocket", 8);
bunch[3] = new Cat("sam", 15);
bunch[4] = bunch[3];
bunch[3] = bunch[0];
System.out.println( bunch[4].getAge() );