Java - Objects & Classes

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is a class?

A template or blueprint from which objects are made.

Can a constructor have return values?

Best practice is NO

What's the purpose of a static field in a class

It is used by all instances of the class to set a value. For example if you want to keep track of employee ids, set a private static nextID field to use as basis

If an instance variable is marked private final is constant?

No, it just means once set in the constructor it cannot be changed for that instance of the class.

What does private access mean on an instance variable?

Only methods that can access the instances fields or are in the class itself

What kind of fields can a static method access

Only static fields

What classes or methods can access a private method?

Only the methods in the class itself. No outside access

How can 'private' instance variables be changed?

Only through accessor and mutator methods of the class

How can a constructor be called?

Only using the 'new' operator.

What is an instance of a class?

When you construct an object from a class it's an instance

What is the basic syntax of a constructor?

public className(......) {.....}

How is the constructor named in a class?

using the same name as the class.

What does public access mean on a method?

Any method in any class in the package can call the method

What are the 3 most common relationships between classes?

Dependence (uses-a) Aggregation (has-a) Inheritance (is-a)

When an instance variable is marked 'private final' what does that mean.

It must be set with the constructor and becomes immutable.

Explain private static final variable

It's an instance variable used by all instances of the a class but the value is set and cannot be changed by any instances.


Set pelajaran terkait

Fund IS Chapter 6 Laws and Regulations

View Set

Chapter 40: Alteration in Gas Exchange/Respiratory Disorder

View Set

Chapter 9 - product strategy, branding, and product management

View Set

GENERAL INFORMATION AND ADVERTISING

View Set

Principles of Auditing and Other Assurance Services, ch.14

View Set

AP US History: From the Beginning to the Great Depression (Real)

View Set