Что такое findslide.org?

FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.


Для правообладателей

Обратная связь

Email: Нажмите что бы посмотреть 

Яндекс.Метрика

Презентация на тему 2. Java Basics. 4. Java Classes

Class – why?Classes split application code to parts (from sophisticated to simple)Very often class is a model of an object from the real worldJava says: Everything is an objectClass describes object behaviourClass is a type*Infopulse Training
2. Java Basics4. Java Classes Class – why?Classes split application code to parts (from sophisticated to simple)Very Class Descriptionclass name {  // field declarations  // method declarations}*Infopulse Training Center Class FieldsClass fields should be declared inside class out of all class Defining Methodsreturn_type  method_name  (parameter_list){  // method body}Example:  int Return TypeThe return type describes the value that comes back from the ParametersAny data type is possible for a parameter of a methodConstruct varargs ConstructorsConstructor name should be the same as class nameConstructor has no return ObjectsCreating Object:	class_name  object_variable = new construtor_call;Declaring a Variable to Refer to Using the this Keywordthis is a reference to the current objectThe most Complex Numbers (1 of 4)Is it always possible to solve square equation Complex Numbers (2 of 4)Is it always possible to solve square equation Complex Numbers (3 of 4)Number of a + b * i type Complex Numbers (4 of 4)To add complex numbers use formulaTo multiply complex Exercise 2.4.1.Create a class for saving and manipulating complex numbers.*Infopulse Training Center Home Exercise 2.4.2 (1 of 2)3D Vector is ordered sequence of 3 Home Exercise 2.4.2 (2 of 2)Scalar product of two vectorsis a numberVector
Слайды презентации

Слайд 2 Class – why?
Classes split application code to parts

Class – why?Classes split application code to parts (from sophisticated to

(from sophisticated to simple)
Very often class is a model

of an object from the real world
Java says: Everything is an object
Class describes object behaviour
Class is a type

*

Infopulse Training Center


Слайд 3 Class Description
class name {
// field declarations

Class Descriptionclass name { // field declarations // method declarations}*Infopulse Training Center

// method declarations
}
*
Infopulse Training Center


Слайд 4 Class Fields
Class fields should be declared inside class

Class FieldsClass fields should be declared inside class out of all

out of all class methods
Fields can have primitive type,

or reference type such as array or object
Fields are visible to all instance methods
Fields are automatically initialized (reference types with null, number types with zero, boolean – with false)

*

Infopulse Training Center


Слайд 5 Defining Methods
return_type method_name (parameter_list){
//

Defining Methodsreturn_type method_name (parameter_list){ // method body}Example: int getFinalData(int a, int

method body
}

Example:
int getFinalData(int a, int r){

int b = r % 18;
return a * 2 + b;
}

*

Infopulse Training Center


Слайд 6 Return Type
The return type describes the value that

Return TypeThe return type describes the value that comes back from

comes back from the method
A method can have void

return type
Any method that is not declared void must contain a return statement with a corresponding return value
Return statements for void return type is not necessary

*

Infopulse Training Center


Слайд 7 Parameters
Any data type is possible for a parameter

ParametersAny data type is possible for a parameter of a methodConstruct

of a method
Construct varargs is used to pass an

arbitrary number of values (e.g. type... args)
Varargs can be used only in the final argument position
Parameters are passed into methods by value.
The values of the object's fields can be changed in the method

*

Infopulse Training Center


Слайд 8 Constructors
Constructor name should be the same as class

ConstructorsConstructor name should be the same as class nameConstructor has no

name
Constructor has no return type
The compiler automatically provides a

no-argument, default constructor for any class without parameters – don’t use this possibility, declare such constructor explicitly
A class can have several constructors (with different sets of parameters)

*

Infopulse Training Center


Слайд 9 Objects
Creating Object:
class_name object_variable = new construtor_call;
Declaring a

ObjectsCreating Object:	class_name object_variable = new construtor_call;Declaring a Variable to Refer to

Variable to Refer to an Object:
class_name object_variable;
Calling an

Object's Methods:
object_variable.methodName(argumentList);

*

Infopulse Training Center


Слайд 10 Using the this Keyword
this is a reference to

Using the this Keywordthis is a reference to the current objectThe

the current object
The most common example:
class Point {

int x = 0;
int y = 0;

//constructor
Point(int x, int y) {
this.x = x;
this.y = y;
}
}


*

Infopulse Training Center


Слайд 11 Complex Numbers (1 of 4)
Is it always possible

Complex Numbers (1 of 4)Is it always possible to solve square

to solve square equation

within real numbers set?


*

Infopulse Training Center


Слайд 12 Complex Numbers (2 of 4)
Is it always possible

Complex Numbers (2 of 4)Is it always possible to solve square

to solve square equation

within real numbers set?
No, if it is impossible.
We can expand real number set to complex number set introducing new number type - complex unit i - in such a way:
i * i = -1


*

Infopulse Training Center


Слайд 13 Complex Numbers (3 of 4)
Number of a +

Complex Numbers (3 of 4)Number of a + b * i

b * i type where a and b are

real is called complex number.
Every square equation can be solved within complex numbers set.
Moreover, every algebraic equation (with arbitrary power) always can be solved within complex numbers set.

*

Infopulse Training Center


Слайд 14 Complex Numbers (4 of 4)
To add complex numbers

Complex Numbers (4 of 4)To add complex numbers use formulaTo multiply

use formula

To multiply complex numbers use formula

To find absolute

value of complex number use formula

*

Infopulse Training Center


Слайд 15 Exercise 2.4.1.
Create a class for saving and manipulating

Exercise 2.4.1.Create a class for saving and manipulating complex numbers.*Infopulse Training Center

complex numbers.
*
Infopulse Training Center


Слайд 16 Home Exercise 2.4.2 (1 of 2)
3D Vector is

Home Exercise 2.4.2 (1 of 2)3D Vector is ordered sequence of

ordered sequence of 3 numbers (vector’s coordinates):

Sum of two

vectors

is a vector

*

Infopulse Training Center



  • Имя файла: 2-java-basics-4-java-classes.pptx
  • Количество просмотров: 136
  • Количество скачиваний: 0