Array of Ref Quiz
By Mickey Arnold
starstarstarstarstarstarstarstarstarstar
Last updated 10 months ago
10 Questions
1 point
1
Question 1
1.
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[6];
System.out.println( x[2] );
1 point
1
Question 2
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[1] );
1 point
1
Question 3
3.
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] = "by";
System.out.println( x[0] );
1 point
1
Question 4
4.
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] );
1 point
1
Question 5
5.
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() );
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() );
1 point
1
Question 6
6.
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 classCat[] 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[0] );
1 point
1
Question 7
7.
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 classCat[] 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];
System.out.println( bunch.length );
1 point
1
Question 8
8.
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 classCat[] 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);
System.out.println( bunch[0].getAge() );
1 point
1
Question 9
9.
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 classCat[] 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] = new Cat("ben", 12);
System.out.println( bunch[3].getAge() );
1 point
1
Question 10
10.
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 classCat[] 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() );
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() );