Preskoči na glavni sadržaj
Prijava
Sign up for FREE
arrow_back
Biblioteka

Array of Ref Quiz

star
star
star
star
star
Posljednje ažuriranje about 2 years ago
10
1
1
1
1
1
1
1
1
1
1
Pitanje 1
1.

What is output by the code below?

String[] x;

x = new String[6];

System.out.println( x[2] );

Pitanje 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] );

Pitanje 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] );

Pitanje 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] );

Pitanje 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() );

Pitanje 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 class

Cat[] bunch = new Cat[5];

System.out.println( bunch[0] );

Pitanje 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 class

Cat[] bunch = new Cat[5];

System.out.println( bunch.length );

Pitanje 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 class

Cat[] bunch = new Cat[5];

bunch[0] = new Cat("rocket", 8);

System.out.println( bunch[0].getAge() );

Pitanje 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 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() );

Pitanje 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 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() );