Quiz
Java Week 5 Object Oriented Programming
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (16)
1To declare a constant MAX_LENGTH as a member of the class, you write
- Afinal static MAX_LENGTH = 99.98
- Bfinal static float MAX_LENGTH = 99.98;
- Cstatic double MAX_LENGTH = 99.98
- Dfinal double MAX_LENGTH = 99.98
- Efinal static double MAX_LENGTH = 99.98
2What 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()));
}
}- Afalse false
- Btrue true
- Cfalse true
- Dtrue false
3The abbreviation OOP stands for
- AObject Only Programming
- BObject Oriented Procedures
- CObject Oriented Programming
- DObject Only Programmers
4In 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"
}
}- Aobject
- Bconstructor
- Cgetter method
- Dsetter method
5Consider 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);
}
}- A5 5
- B10 5
- C5 10
- D5 0
6In 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;
}
}- Agetter method
- Bsetter method
- Cconstructor method
- Dinstance variable initialization
7A method that is associated with an individual object is called
- Astatic method
- Bclass method
- Can instance method
- Dan object method
8In 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;
}
}- Asetter method
- Bgetter method
- Cconstructor method
- Dobject initialization
9What 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");
}
}- As1 and 2 reference to the same object
- Bs1 and s2 reference to difference String objects
10Which 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();
}
}- AA
- BB
- CNeither
- DBoth
11The variables that an object contains are called local variables
- ATrue
- BFalse
12The area of memory that objects reside in is known as the stack
- ATrue
- BFalse
13In the following code, the object created from class Student is stored in the variable myStudent.
Student myStudent;
myStudent = new Student();- ATrue
- BFalse
14When a programmer neglects to delete objects that are no longer used it is referred to as a memory leak
- ATrue
- BFalse
15In java, Garbage Collection is the process that reclaims the memory used by objects which are no longer in use
- ATrue
- BFalse
16In java no variable can ever hold an object.
It can only hold a reference to an object.- ATrue
- BFalse
Information
- Description
- AS - Level Computer Science (CS1102 Java) Quiz on Java Week 5 Object Oriented Programming , created by Troy Bowlin on 02/10/2016.
- Author
- Troy Bowlin
- Language
- English
- Views
- 632
- Tags
- Rating
- No ratings yet Rate this quiz