Comp Sci Fart

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:41 AM on 8/25/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

19 Terms

1
New cards

Object

An object is something that contains both state & behavior. They are instances if classes, and are specific versions of a class.

2
New cards

Class

The class is a template for creating an object.

3
New cards

Instance

A instance is a specific version of a class (same thing as an object).

4
New cards

Client of a Class

Using the methods and functionality without necessarily understanding how it works.

5
New cards

Constructor


Correct Answer

A constructor allows us to create a new instance of a class, usually initializing instance variables.

public Flower(String theName, String theColor, String theGenus, String theSpecies){}

6
New cards
<p><span>Which of the following is the correct </span><code>/* implementation */</code><span> code for the constructor in the Card class?</span></p>

Which of the following is the correct /* implementation */ code for the constructor in the Card class?

The private instance variables suit and value need to be initialized to the appropriate parameter values, cardSuit and cardValue, respectively, in the constructor.

<p><span>The private instance variables </span><code>suit</code><span> and </span><code>value</code><span> need to be initialized to the appropriate parameter values, </span><code>cardSuit</code><span> and </span><code>cardValue</code><span>, respectively, in the constructor.</span></p>
7
New cards

Instance Method

An instance method is a piece of code called on a specific instance of the class. It is called with a receiver object.

int area = rectangle1.getArea();

8
New cards

Is there a difference between a getter and a accessor method?

No, they refer to the same idea.

9
New cards

Getter Method

A getter method lets you get access to some instance variables of an object.

public String getSender()

{

return sender;

}

10
New cards

Setter Method

A setter method lets you set the values of instance variables of an object.

public void setNumerator(int theNumerator)

{

numerator = theNumerator;

}

11
New cards

Why use getter and setter methods?

Validation, hide internal representation, may need to add more logic to these methods, safety- can control better what a client can access.

12
New cards

Class Methods

A method of a class that is common to all instances of a class, and is not called on an object instance.

13
New cards

Class Variables

A variable or attribute of a class that is common to all instances of a class.

14
New cards

Static Variables/Static Methods

If a variable or method belongs to the class and not the instance, it is considered a class variable or class method.

int x = Math.abs(-5); , private static int totalStudents = 0;

15
New cards

Wrapper Class

Wrapper classes provide a way to wrap primitive values in an object, so that primitive can do activities reserved for objects. Integer, Double.

Integer x = new Integer(12);

16
New cards

Autoboxing

Converting a primitive value to an object of a corresponding wrapper class. The Java compiler will also apply auto boxing when a primitive value is passed as a parameter to a method that expects an object of the corresponding wrapper class. It helps us write cleaner code.

Integer myInt = 53;

17
New cards

Unboxing

Converting an object of a wrapper type to its corresponding primitive value. The Java compiler will also apply unboxing when a wrapper value is passed as a parameter to a method that expects a primitive value.

Integer myInt = 53;

int myInt2 = myInt; ← unboxing

18
New cards

Java automatically converts between objects and primitives in the process of autoboxing and unboxing.

What happens when a Double is unboxed?

A Double is unboxed when it is converted to a primitive value.

19
New cards

Java automatically converts between objects and primitives in the process of autoboxing and unboxing.

What happens when a int is autoboxed?


Correct Answer

A int is autoboxed when it is converted to a Integer