Troy Bowlin
Quiz von , erstellt am more than 1 year ago

AS - Level Computer Science (CS1102 Java) Quiz am Java Week 5 Object Oriented Programming , erstellt von Troy Bowlin am 02/10/2016.

484
1
0
Troy Bowlin
Erstellt von Troy Bowlin vor mehr als 7 Jahre
Schließen

Java Week 5 Object Oriented Programming

Frage 1 von 16

1

To declare a constant MAX_LENGTH as a member of the class, you write

Wähle eine der folgenden:

  • final static MAX_LENGTH = 99.98

  • final static float MAX_LENGTH = 99.98;

  • static double MAX_LENGTH = 99.98

  • final double MAX_LENGTH = 99.98

  • final static double MAX_LENGTH = 99.98

Erklärung

Frage 2 von 16

1

What is the output of the following code:
import java.util.Date;
public class Test {
public static void main (String[] args) [
Date date1 = new Date();
Date date2 = new Date();
System.out.print((date1 == date2) + "" + (date1.getClass() == date2.getClass()));
}
}

Wähle eine der folgenden:

  • false false

  • true true

  • false true

  • true false

Erklärung

Frage 3 von 16

1

The abbreviation OOP stands for

Wähle eine der folgenden:

  • Object Only Programming

  • Object Oriented Procedures

  • Object Oriented Programming

  • Object Only Programmers

Erklärung

Frage 4 von 16

1

In the following code, what is the newStudent method called:
public class newStudent{
public String name;
public int age;

public newStudent(){
age=5;
name = "Jim Jones"
}
}

Wähle eine der folgenden:

  • object

  • constructor

  • getter method

  • setter method

Erklärung

Frage 5 von 16

1

Consider the following code, which output is correct?
public class Student{
int age;
static int age2 = 3;

public static void main (String[] args){
Student student1;
Student student2;
Student student3;

student1 = new Student();
student1.age = 10;
student2 = student1;
student2.age -=5;
student 3 = new Student();
System.out.println(student1.age+:""+student2.age);
}
}

Wähle eine der folgenden:

  • 5 5

  • 10 5

  • 5 10

  • 5 0

Erklärung

Frage 6 von 16

1

In the following code what is the getName() method referred to:
public class Student {
public String name;
public int age;
public String getName(){
return name;
}
public void setName(String newName){
name = newName;
}
}

Wähle eine der folgenden:

  • getter method

  • setter method

  • constructor method

  • instance variable initialization

Erklärung

Frage 7 von 16

1

A method that is associated with an individual object is called

Wähle eine der folgenden:

  • static method

  • class method

  • an instance method

  • an object method

Erklärung

Frage 8 von 16

1

In the following code what is the setName() method referred to:
public class Student{
public String name;
public int age;
public String getName(){
return name;
}
public void setName( String newName){
name = newName;
}
}

Wähle eine der folgenden:

  • setter method

  • getter method

  • constructor method

  • object initialization

Erklärung

Frage 9 von 16

1

What is the output of the following code?
public class Test{
public static void main (String[] args) {
String s1 = new String ("Welcome to Java!");
String s2 = new String("Welcome to Java!");
if (s1==s2)
System.out.println("s1 and s2 reference to the same String object");
else
System.out.println("s1 and s2 reference to different String objects");
}
}

Wähle eine der folgenden:

  • s1 and 2 reference to the same object

  • s1 and s2 reference to difference String objects

Erklärung

Frage 10 von 16

1

Which of the following code in A or B, or both creates an object of the java.util.Date class?
A:
public class Test{
public Test(){
new java.util.Date();
}
}
B:
public class Test {
public Test(){
java.util.Date date = new java.util.Date();
}
}

Wähle eine der folgenden:

  • A

  • B

  • Neither

  • Both

Erklärung

Frage 11 von 16

1

The variables that an object contains are called local variables

Wähle eins der folgenden:

  • WAHR
  • FALSCH

Erklärung

Frage 12 von 16

1

The area of memory that objects reside in is known as the stack

Wähle eins der folgenden:

  • WAHR
  • FALSCH

Erklärung

Frage 13 von 16

1

In the following code, the object created from class Student is stored in the variable myStudent.
Student myStudent;
myStudent = new Student();

Wähle eins der folgenden:

  • WAHR
  • FALSCH

Erklärung

Frage 14 von 16

1

When a programmer neglects to delete objects that are no longer used it is referred to as a memory leak

Wähle eins der folgenden:

  • WAHR
  • FALSCH

Erklärung

Frage 15 von 16

1

In java, Garbage Collection is the process that reclaims the memory used by objects which are no longer in use

Wähle eins der folgenden:

  • WAHR
  • FALSCH

Erklärung

Frage 16 von 16

1

In java no variable can ever hold an object.
It can only hold a reference to an object.

Wähle eins der folgenden:

  • WAHR
  • FALSCH

Erklärung