Java Methods and Classes

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

Method parameters

part of the method that receives data. the data must the same type and in the same order as it is stated in the method declaration.

boolean equalsIgnoreCase (String str)

returns true if this string contains the same characters as str and false if it doesn't. Ignores lower and upper case.

Constructors and methods can call other public/ private methods of the ____ class

same

Method

set of instructions that are used when called.

Inheritance

Creating a new class based on a previously defined class.

int compareTo(int Num)

If the Integer is equal to the argument then 0 is returned. If the Integer is less than the argument then -1 is returned. If the Integer is greater than the argument then 1 is returned.

Constructor

a method that allows you to create objects from a class. You call the constructor by using the keyword new, followed by the name of the class, followed by any necessary parameters.

String concat(String str)

adds the specified string to the end of original string

Class

blueprint in which objects are created

return

causes a method to end and sends a value back to the statement that called the method.

Abstract Class

class that contains one or more abstract methods. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.

Subclass

class that inherits from another class.

Void Method

does not return a value

Abstract Method

has a name, parameters, and a return type, but no code in the body of the method.

Precondition

initial requirements of the method. it is normally stated as part of the methods documentation.

Call

method name followed by parenthesis. Ex: calculate();

Accessors

methods that gets a value from a class's field, but does not change it.

Mutators

methods that stores a value in a field or in some other way changes the value of a field.

Structure of a method

modifier returnType name(parameters) { } EX: public static int calculate(int x, int y) { }

Constructors and methods can call only ______ methods of another class.

public

String substring (int startIndex, int endIndex)

returns new string that is subset of this string starting at index startIndex and index endIndex -1, or if no endIndex, it goes to the end of the string.

String toLowerCase()

returns new string that is the same except all letters are in lowercase.

String toUpperCase()

returns new string that is the same except all letters are in uppercase.

int length ()

returns number of characters in the string.

int indexOf (String str)

returns position of the first character in the first occurrence of str in this string.

char charAt (int index)

returns the character at the specified index.

boolean equals (String str)

returns true if this string contains the same characters as str and false if it doesn't.

The ____reserved word is used to deactivate polymorphism and invoke a method of the superclass.

super

Argument

value passed to a method

Method Overloading

Two or more methods with the same name but different parameter types, order, and/or number of parameters. When overloaded methods are called, the compiler decides which one to use based on the number, order, and type of parameter.


Ensembles d'études connexes

Life Insurance: Group Life Insurance, Retirement Plans, and Social Security Disability Program

View Set

Chapter 10 - Pay for Performance: Incentive Rewards DONE

View Set

Principles of Auditing Chapter 5

View Set