Java- Object & Classes

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Three steps when creating an object from a class

-Declaration: A variable declaration with a variable name with an object type

Class

A class can be defined as a template/blueprints that describes the behaviours/ states that object of its type support. A class can contain: local variables, instance variables, class variables.

class variables

Class variables are variables declared with in a class, outside any method, with the static keyword.

Instance variables

Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.

Software objects

It also have a state and behaviour. A software object's state is stored in fields and behaviour is shown via methods.

Object

Objects have states and behaviours. Ex: A dog has states- colour, name, breed as well as behaviours- wagging, barking, eating. An object is an instance of a class. An object is created from a class. In Java, the new key word is used to create new objects

Initialization

The 'new' keyword is followed by a call to a constructor. This call initializes the new object.

Instantiation

The 'new' keyword is used to create the object

local variables

Variables defined inside methods, constructors or blocks. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.


Ensembles d'études connexes

Cross Sectional Anatomy Chp 9 Upper Extremities

View Set

Heat and Temperature Science Test

View Set

Evidence Based All Chapters Review

View Set

Chapter 45: Concepts of Care for Patients with Musculoskeletal Problems

View Set