Java Week 5 Object Oriented Programming

Descrição

AS - Level Computer Science (CS1102 Java) Quiz sobre Java Week 5 Object Oriented Programming , criado por Troy Bowlin em 02-10-2016.
Troy Bowlin
Quiz por Troy Bowlin, atualizado more than 1 year ago
Troy Bowlin
Criado por Troy Bowlin aproximadamente 8 anos atrás
518
1

Resumo de Recurso

Questão 1

Questão
To declare a constant MAX_LENGTH as a member of the class, you write
Responda
  • 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

Questão 2

Questão
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())); } }
Responda
  • false false
  • true true
  • false true
  • true false

Questão 3

Questão
The abbreviation OOP stands for
Responda
  • Object Only Programming
  • Object Oriented Procedures
  • Object Oriented Programming
  • Object Only Programmers

Questão 4

Questão
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" } }
Responda
  • object
  • constructor
  • getter method
  • setter method

Questão 5

Questão
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); } }
Responda
  • 5 5
  • 10 5
  • 5 10
  • 5 0

Questão 6

Questão
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; } }
Responda
  • getter method
  • setter method
  • constructor method
  • instance variable initialization

Questão 7

Questão
A method that is associated with an individual object is called
Responda
  • static method
  • class method
  • an instance method
  • an object method

Questão 8

Questão
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; } }
Responda
  • setter method
  • getter method
  • constructor method
  • object initialization

Questão 9

Questão
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"); } }
Responda
  • s1 and 2 reference to the same object
  • s1 and s2 reference to difference String objects

Questão 10

Questão
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(); } }
Responda
  • A
  • B
  • Neither
  • Both

Questão 11

Questão
The variables that an object contains are called local variables
Responda
  • True
  • False

Questão 12

Questão
The area of memory that objects reside in is known as the stack
Responda
  • True
  • False

Questão 13

Questão
In the following code, the object created from class Student is stored in the variable myStudent. Student myStudent; myStudent = new Student();
Responda
  • True
  • False

Questão 14

Questão
When a programmer neglects to delete objects that are no longer used it is referred to as a memory leak
Responda
  • True
  • False

Questão 15

Questão
In java, Garbage Collection is the process that reclaims the memory used by objects which are no longer in use
Responda
  • True
  • False

Questão 16

Questão
In java no variable can ever hold an object. It can only hold a reference to an object.
Responda
  • True
  • False

Semelhante

Cells And Cell Techniques - Flashcards (AQA AS-Level Biology)
Henry Kitchen
AQA Biology 12.1 cellular organisation
Charlotte Hewson
AS Biology Unit 1
lilli.atkin
PSYA1 - attachment, AQA psychology
T W
Biological Psychology - Stress
Gurdev Manchanda
The Heart
annalieharrison
OCR Chemistry - Atoms, Bonds and Groups (Definitions)
GwynsM
Memory Key words
Sammy :P
AQA Biology 11.2 mitosis
Charlotte Hewson
AQA Biology 11.1 replication of DNA
Charlotte Hewson
Alcohols
Bee Brittain