(New) CS 1331 Final Exam Review Terms

studied byStudied by 77 people
5.0(1)
Get a hint
Hint

type

1 / 165

flashcard set

Earn XP

Description and Tags

166 Terms

1

type

A class is a "____"

New cards
2

Data and methods

What are the two main attributes of a class?

New cards
3

Instance data

Values that are within the class but not within the methods; generally placed at the top of the class

New cards
4

copy

Each object that gets instantiated for the class gets its own ____ of the instance variables

New cards
5

Methods

functions/procedures (behaviors) within the class

New cards
6

body

public double meth1(int var1, int var2) {
double total;
total = var1 * var2;
return total;
}

//What is the content of the method referred to as?
New cards
7

Return statement

control immediately goes back to call

New cards
8
return;

What is the return statement for a void method?

New cards
9

Local variables

Variables declared inside a method, and are only accessible in that method. In other words, the scope of these variables is the method in which they were created.

New cards
10

Parameters

Variables passed into a method

New cards
11

Formal paramaters

Names of the parameters in the header declaration

New cards
12

Actual paramaters

Values passed in when running

New cards
13

T

(T/F) Arrays can be parameters

New cards
14

Static methods

Methods that are not called in the context of an object.

New cards
15

Non-static methods

Methods that are always called in the context of an object

New cards
16
this

A Java reserved word that is used inside methods. It refers to the object upon which the method was invoked.

New cards
17

Class interface

A group of specified certain methods for outsiders to use

New cards
18

Visibility modifiers

Modifiers that control access

New cards
19
public

Modifier that allows anyone to access instance data and methods

New cards
20
private

Modifier that only allows the class itself to access instance data and methods (i.e. objects of that class)

New cards
21
protected

Modifier that allows a subclass to access instance data and methods from its super class, vice versa, and classes within the same package

New cards
22

Constructor

A special method that is automatically called when objects are instantiated.

New cards
23

initialize

A constructor's primary use is to _______ instance variables.

New cards
24

Scope

The region of a program where variables are accessible.

New cards
25

Overloading

The use of the same name with different paramater lists (types) to create multiple versions of a method

New cards
26

Method signature

The part of a method declaration that includes the name, along with the paramater type and order.

Example:

meth1(int var1, int var2)
New cards
27

F

(T/F) A method signature includes the return type of that method

New cards
28

T

(T/F) Constructors can be overloaded

New cards
29
this(v1, v2, v3);

What is the proper syntax for a chained constructor call? (use 3 variables, denoting them as v1, v2, v3)

New cards
30

F

(T/F) A constructor must always have parameters as input

New cards
31

B

If a constructor for a class is not written, Java provides one for you when you create an object of that class. However, if you provide one with pamaraters, and you create an object with no paramaters, what happens?

A. The object is created with default values, and the code compiles.
B. The compiler will throw an exception.

New cards
32

A

int a; 

What is this an example of?

A. Declaration

B. Initialization

C. Instantiation

New cards
33

A

String s;  

What is this an example of?

A. Declaration

B. Initialization

C. Instantiation

New cards
34

B

int a;
 a = 0; //What does this line represent?

A. Declaration

B. Initialization

C. Instantiation

New cards
35

C

String s;
s = new String(“Hello”); //What does this line represent?

A. Declaration

B. Initialization

C. Instantiation

New cards
36
equals()

If we want to check whether two objects contain the same values, what method or operator do we use (hint: primarily used for objects)?

New cards
37
==

If we want to check whether two objects reference the same data, what method or operator do we use (hint: primarily used for primitive types)?

New cards
38
toString()

The method invoked when an attempt to print an object of that type occurs

New cards
39
static

A modifier that creates one copy of a variable or method that is shared by all instances of the class

New cards
40

In the class

Where is the memory space for static variables located?

New cards
41

F

(T/F) Static methods can reference instance variables

New cards
42
null

A reserved word for objects that have no reference; can occur after declaration but no instantiation

New cards
43

Copy constructor

A special type of constructor that takes in an object of that class and "copies" its contents. When called, an object with the same values as the paramater object will be created.

New cards
44

Wrapper classes

A class that corresponds to a primitive type. Allows the usage of primitive types as objects. i.e. Integer, Double, etc.

New cards
45

T

(T/F) Java will automatically convert between primitive and Wrapper when needed

New cards
46

Auto-boxing

Converting a wrapper to a primitive type

New cards
47

Unboxing

Converting a primitive type to a Wrapper

New cards
48

Javadoc

Documenting your code

New cards
49

Inheritance

The process of deriving a new class from an existing one. Automatically contains some or all of the methods of the original. Can add new ones to it.

New cards
50
extends

A keyword that denotes that a class is a subclass of a super class; placed in class header

New cards
51

is-a

What type of hierarchy represents the super-sub class relationship?

New cards
52
super

keyword for denoting access to parent's members

New cards
53
super(v1);

What is the proper syntax for calling the constructor of the parent class from the child class? Use "v1" as the variable.

New cards
54

F

(T/F) When using the super() call in the constructor of the child class, this line of code can appear anyhwere within the body of the constructor.

New cards
55

T

(T/F) If the first line of a sub-class constructor is not an explicit call to a super class constructor, Java inserts super() automatically.

New cards
56

Overriding

When a child class defines a method with the same name (and signature) as the parent, child's version overrides the parent's version

New cards
57
@Override

What is the correct syntax for notifying the compiler of a method override for a child class?

New cards
58

F

(T/F) Static methods can be inherited and overridden

New cards
59

single

Java has _____ inheritance; it can extend at most one class

New cards
60
Object

The class that all classes are ultimately derived from. Contains methods such as equals(), toString(), clone().

New cards
61
instanceof

keyword that checks if an object is an instance of another class

New cards
62
getClass()

Method that returns the class an object is an instance of

New cards
63
this(xxxx);

chained constructor call (use xxxx as param, variable, or method name)

New cards
64
this.xxxx;

Instance data of object that is being called upon.
(use xxxx as param, variable, or method name)

New cards
65
this.xxxx();

Calling a method within the class, do not necessarily need "this"
(use xxxx as param, variable, or method name)

New cards
66
super(xxxx);

calling super class constructor
(use xxxx as param, variable, or method name)

New cards
67
super.xxxx;

Accessing instance variable from super class. (use xxxx as param, variable, or method name)

New cards
68

Abstract

a “placeholder;” useful for super and sub classes in which the super class contains a abstract method that must be included in the subclasses.

New cards
69

F

(T/F) Abstract classes cannot contain non-abstract methods

New cards
70

T

(T/F) In order for an abstract method to exist, the subclasses must either override the method or be absract themselves.

New cards
71

can

Abstract methods (can/can’t) have concrete constructors.

New cards
72

F

(T/F) You can instantiate an abstract class with new()

New cards
73
final

A keyword that is used to denote that a class cannot be extended, the value of a variable cannot be changed, or that a method cannot be overridden.

New cards
74

Static type

A variable’s type at compile time; what class the object is declared as

New cards
75

Person

Suppose a Person class with a constructor and methods is created. Also suppose that a subclass named Student is created and extends Person. Now, suppose we create a Person object p and write the following lines of code.

Person p;
p = new Student(“Mary”, 1);
//What is the static type of p?
New cards
76

Dynamic type

the type of object a variable references at run-time; the class an object is instantiated as.

New cards
77

Dentist

Suppose a Person class with a constructor and methods is created. Also suppose that a subclass named Dentist is created and extends Person. Now, suppose we create a Person object p and write the following lines of code (assume “xxxx” are paramaters).

Person p;
p = new Dentist(xxxx);
//What is the dynamic type of p?
New cards
78

F

(T/F): If you do not write a toString() method for a class and attempt to print an object that is an instance of that class, you will get a compiler error.

New cards
79
public abstract void method1()

Write the method declaration of an abstract void method that takes no parameters, is public, and is named “method1”.

New cards
80

Polymorphism

To have many forms. This allows us to deal with diverse (but related) members of a group in a general way.

New cards
81

yes

Suppose a class Animal is defined, and Bird is another defined class that is a subclass of Animal. Are the following lines of code legal? (yes/no)

Animal a1;
a1 = new Bird();
New cards
82

no

Suppose a class Animal is defined, and Bird is another defined class that is a subclass of Animal. Are the following lines of code legal? (yes/no)

Animal a1;
Bird b1 = new Animal();
New cards
83

T

(T/F) We can assign or subsittute a member of a subclass for a memer of a parent class, but not vice versa

New cards
84

Dynamic binding

Binding of which type of object is “in there” and influences the call is is deferred until run-time; Compiler simply insures either way is legal.

New cards
85

dynamic

Suppose obj is an instantiated object of some subclass, and meth() is a method that exists in both the parent and super class. The method that was invoked on a obj.meth() call is determined by the ____ run-time type of obj.

New cards
86

lowest

In a chain of multiple subclasses, whatver class is ____ in hierarchy determines which methods are called.

New cards
87

F

(T/F) You cannot cast an object down the hierarchy (casting parent to a child)

New cards
88

T

(T/F) It is possible for valid casts to fail at run-time.

New cards
89

Generics

Classes and method definitions with types. You write a _____ class/method, then it can be created to handle any different type of object.

New cards
90

ArrayList

Like an array, like a list (can grow in size).

New cards
91
import java.util.ArrayList;

Write the line of code that imports an ArrayList for use.

New cards
92
ArrayList<Type> list = new ArrayList<>();

How do you correctly declare and instantiate an ArrayList? Use “Type” and “list” in your answer when appropriate.

New cards
93

to the right

When you add an object to an ArrayList at a particular index, which way does the rest of the list shift?

New cards
94

Interfaces

Specification of a set of abstract behaviors (methods). Classes choose to provide these behaviors and then advertise themselves as doing so.

New cards
95

F

(T/F) A class does not have to implement every method in the interface it implements.

New cards
96

T

(T/F) A class can have other methods besides the ones it implements from an interface.

New cards
97

F

(T/F) An interface is a class.

New cards
98

T

(T/F) Interfaces can be in hierarchies

New cards
99

Recursion

One made to same method as resident in; The process of calling a method within the method itself.

New cards
100

F

(T/F) Recursive calls are essentially “calling yourself”

New cards

Explore top notes

note Note
studied byStudied by 3 people
... ago
5.0(1)
note Note
studied byStudied by 4 people
... ago
4.0(1)
note Note
studied byStudied by 8 people
... ago
5.0(1)
note Note
studied byStudied by 13 people
... ago
5.0(1)
note Note
studied byStudied by 20 people
... ago
5.0(2)
note Note
studied byStudied by 17 people
... ago
4.7(3)
note Note
studied byStudied by 8 people
... ago
5.0(1)
note Note
studied byStudied by 10405 people
... ago
4.8(44)
robot