Download presentation
Presentation is loading. Please wait.
Published byGabriella Parrish Modified over 9 years ago
1
Mason Vail
2
A data type definition – “blueprint for objects” Includes properties and/or methods ◦ “instance” data / methods – specific to one object (instance) of the class ◦ “static” or “class” data / methods – belongs to the class itself, shared by all objects of the type
3
One instance of a data type Looks and acts like other objects of the same type, but has its own identity and state independent of other objects
4
One of the central pillars of object-oriented design Idea that each object is in control of its own state (instance data) and outsiders are required to interact with the object through its limited public interface (set of methods)
5
Visibility regulates the exposure of data and methods ◦ “public” – accessible to any outside entity with a reference to the object ◦ “protected” – default visibility – accessible to child objects or any other entity defined in the same package ◦ “private” – accessible only within the class/object All data / methods should be private until a good reason is given to relax visibility
6
A named set of statements within a class that carry out a specific task Public methods make up the public interface of an object Protected/private methods generally serve as supporting utility methods for carrying out intermediate tasks for the object
7
The class containing the main() method, where a program begins The class invoked by name when launching the Java Runtime Environment (JRE)
8
The most basic linear data structure for storing multiple values of the same type In some languages, they are a primitive data type, but in Java arrays are objects, though they have special syntax that makes them look a little different than other objects
9
As objects, arrays must be instantiated with a constructor call before they can be used ◦ int[] a = new int[10]; //creates an array with room for 10 ints The size of an array, once instantiated, is immutable
10
Arrays can be multidimensional – each dimension can be of a different size 2D arrays (“tables”) are common The first dimension of a 2D array is commonly considered to be the row reference The second dimension of a 2D array is commonly considered to be the column
11
Any multidimensional array can be thought of as an “array of arrays” until the last dimension is accessed and an individual value of the array type is reached int[][] someArray = new int[5][10]; ◦ someArray is an array of int[]s of length 5 ◦ someArray[0] is in int[] of length 10
12
A primitive variable is a named memory location containing a value of the primitive type An object reference variable contains the address of an object somewhere else in memory
13
Making a copy of a primitive variable duplicates the value, after which the two variables have no effect on the other Making a copy of an object reference creates an alias – a duplicate reference to the same object – so changes can be made to the object via any of its aliased references Copying an object requires instantiating a new, independent object and explicitly duplicating the state of the original object in the new object
14
A collection of bodiless, abstract method signatures defined in a.java file May be implemented by one or more classes Not a class – may not be instantiated
15
Accessor (“getter”) methods – methods with the special purpose of returning object information without violating encapsulation ◦ Returned values are typically already known – the method only needs to return an independent copy of instance data Mutator (“setter”) methods – methods with the special purpose of updating object state without violating encapsulation ◦ Changing data takes the form of a request, rather than a demand – the object has the opportunity to validate input and enforce its own rules about updating its state
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.