class

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Methods

define the behaviors or functions for objects.

object.method(arguments).

Some methods take parameters/arguments that are placed inside the parentheses

object.method();

To use an object's method, you must use the object name and the dot (.) operator followed by the method name

Need to know

Values provided in the parameter list need to correspond to the order and type in the method signature. Some methods return values. To use the return value when calling a method, it must be stored in a variable or used as part of an expression. The variable data type must match the return type of the method.

no-argument constructor

a constructor that doesn't take any passed in values (arguments).

new

a keyword that is used to create a new object of a class. The syntax is new ClassName(). It creates a new object of the specified class and calls a constructor.

method

a set of instructions that define the behaviors for all objects of the class.

object

a specific instance of a class with defined attributes. Objects are declared as variables of a class type.

Parameters

allow values to be passed to the constructor to initialize the newly created object's attributes.

Procedural abstraction

allows a programmer to use a method by knowing in general what it does without knowing what lines of code execute. This is how we can drive a car without knowing how the brakes work.

method or constructor

call interrupts the sequential execution of statements, causing the program to first execute the statements in the method or constructor before continuing. Once the last statement in the method or constructor has executed or a return statement is executed, the flow of control is returned to the point immediately following the method or constructor call.

attribute or instance variable

data the object knows about itself. For example a turtle object knows the direction it is facing or its color.

parameter list

in the header of a constructor, is a list of the type of the value being passed and a variable name. These variables are called the formal parameters.

Constructors

initialize the attributes in newly created objects. They have the same name as the class.

static method or class method

method is one that doesn't need to be called on an object of a class.

object method or non-static method

one that must be called on an object of a class. It usually works with the object's attributes.

behavior or method

something that an object can do. For example a turtle object can go forward 100 pixels.

constructor signature

the constructor name followed by the parameter list which is a list of the types of the parameters and the variable names used to refer to them in the constructor.

method signature

the method name followed by the parameter list which gives the type and name for each parameter. Note that methods do not have to take any parameters, but you still need the parentheses after the method name.

Formal parameters

the specification of the parameters in the constructor header. In Java this is a list of the type and name for each parameter (World(int width, int height).

Actual parameters

the values being passed to a constructor. The formal parameters are set to a copy of the value of the actual parameters.

dot notation

to execute an object's method. This is the object's name followed by the dot (.) operator followed by the method name and parentheses: object.method();

Overloading

when there is more than one constructor. They must differ in the number, type, or order of parameters.

Call by value

when you pass a value to a constructor or method it passes a copy of the value.

NullPointerException

will happen if you try to call an object method on an object variable whose value is null. This usually means that you forgot to create the object using the new operator followed by the class name and parentheses.


संबंधित स्टडी सेट्स

Chemistry Unit 4- Electrons in atoms

View Set

Urbanization (unit 8) reading guide

View Set

Cardiovascular Flashcards, Exam two

View Set

Cell and Molecular Biology Final Exam

View Set

Module 2 Chapter 6 Network Essentials

View Set