🗊Презентация Class and Object. Java Core

Нажмите для полного просмотра!
Class and Object. Java Core, слайд №1Class and Object. Java Core, слайд №2Class and Object. Java Core, слайд №3Class and Object. Java Core, слайд №4Class and Object. Java Core, слайд №5Class and Object. Java Core, слайд №6Class and Object. Java Core, слайд №7Class and Object. Java Core, слайд №8Class and Object. Java Core, слайд №9Class and Object. Java Core, слайд №10Class and Object. Java Core, слайд №11Class and Object. Java Core, слайд №12Class and Object. Java Core, слайд №13Class and Object. Java Core, слайд №14Class and Object. Java Core, слайд №15Class and Object. Java Core, слайд №16Class and Object. Java Core, слайд №17Class and Object. Java Core, слайд №18Class and Object. Java Core, слайд №19Class and Object. Java Core, слайд №20Class and Object. Java Core, слайд №21Class and Object. Java Core, слайд №22Class and Object. Java Core, слайд №23Class and Object. Java Core, слайд №24Class and Object. Java Core, слайд №25Class and Object. Java Core, слайд №26Class and Object. Java Core, слайд №27Class and Object. Java Core, слайд №28

Вы можете ознакомиться и скачать презентацию на тему Class and Object. Java Core. Доклад-сообщение содержит 28 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1





Class and Object 
Java Core
Описание слайда:
Class and Object Java Core

Слайд 2





Agenda
Class and Object 
Access to data
Fields of class
Getters and Setters 
Constructors
Methods of class
Creating objects
Examples
Описание слайда:
Agenda Class and Object Access to data Fields of class Getters and Setters Constructors Methods of class Creating objects Examples

Слайд 3





Class and Object
A class is a prototype (template) from which objects are created
An object is a software bundle of related state and behavior
Описание слайда:
Class and Object A class is a prototype (template) from which objects are created An object is a software bundle of related state and behavior

Слайд 4





Class
<access specifier> class ClassName {
	// fields
	<access specifier> <data type> variable1; 
	...
	<access specifier> <data type> variableN;
        
	// constructors 
       <access specifier> ClassName(parameter_list1){ 
	    // method body 	}       
	...
	 <access specifier> ClassName(parameter_listN){ 
	    // method body 	}
	// methods 
       <access specifier> <return type> method1(parameter_list){ 
	    // method body 	} 
	...
	 <access specifier> <return type> methodN(parameter_list){ 
	    // method body 	}
Описание слайда:
Class <access specifier> class ClassName { // fields <access specifier> <data type> variable1; ... <access specifier> <data type> variableN; // constructors <access specifier> ClassName(parameter_list1){ // method body } ... <access specifier> ClassName(parameter_listN){ // method body } // methods <access specifier> <return type> method1(parameter_list){ // method body } ... <access specifier> <return type> methodN(parameter_list){ // method body }

Слайд 5





Class
Описание слайда:
Class

Слайд 6





Access to data
public class Student {...}
private int age;
public void print(){}
              Controlling Access to Members of a Class 
        Class Package Subclass World
private 	 Y	  —		—	  —
(not)		 Y	  Y		—	  —
protected	 Y	  Y		Y	  —
public	 Y	  Y		Y	  Y
Описание слайда:
Access to data public class Student {...} private int age; public void print(){} Controlling Access to Members of a Class Class Package Subclass World private Y — — — (not) Y Y — — protected Y Y Y — public Y Y Y Y

Слайд 7





Special Requirements to source files
a source code file (.java) can have only one public class
name of this class should be exactly the same of file name before extension (including casing)
source code file can have any number of non-public classes
most code conventions require use only one top-level class per file
Описание слайда:
Special Requirements to source files a source code file (.java) can have only one public class name of this class should be exactly the same of file name before extension (including casing) source code file can have any number of non-public classes most code conventions require use only one top-level class per file

Слайд 8





Default values for fields
Описание слайда:
Default values for fields

Слайд 9





Type casting
Widening (implicit or automatic) type casting take place when, the two types are compatible the target type is larger than the source type
Описание слайда:
Type casting Widening (implicit or automatic) type casting take place when, the two types are compatible the target type is larger than the source type

Слайд 10





Methods and overloading
Methods are functions that are executed in context of object
Always have full access to data of object
Object can have multiple methods with same name but different signature (type and order of parameters)
Signature doesn't include return type, methods can't be overloaded by return types
Описание слайда:
Methods and overloading Methods are functions that are executed in context of object Always have full access to data of object Object can have multiple methods with same name but different signature (type and order of parameters) Signature doesn't include return type, methods can't be overloaded by return types

Слайд 11





Variable length arguments
Methods in Java support arguments of variable length
Should be last argument in method definition
Описание слайда:
Variable length arguments Methods in Java support arguments of variable length Should be last argument in method definition

Слайд 12





Access to fields
The following class uses public access control:
	public class Student {
  public String name;
  public int age;
  ...
	} 
 Student stud = new Student();
 stud.name = “Krystyna”;
 stud.age = 22;
Описание слайда:
Access to fields The following class uses public access control: public class Student { public String name; public int age; ... } Student stud = new Student(); stud.name = “Krystyna”; stud.age = 22;

Слайд 13





Getters and Setters
The following class uses private access control:
public class Student {
    private String name;
    public String getName() {
        return this.name;
    }
     public void setName(String name) {
        this.name = name;
    }
}
Описание слайда:
Getters and Setters The following class uses private access control: public class Student { private String name; public String getName() { return this.name; } public void setName(String name) { this.name = name; } }

Слайд 14





Getters and Setters
Student student = new Student();
  student.setName(“Franko”);
  
  String nameStud =
		 student.getName();
Описание слайда:
Getters and Setters Student student = new Student(); student.setName(“Franko”); String nameStud = student.getName();

Слайд 15





Getters and Setters can be Complex
public class Sum {
   private int a, b, c;
   void setA(int m) { this.a = m; c = a + b; }
   void setB(int n) { this.b = n; c = a + b; }
   int getA() { return this.a; }
   int getB() { return this.b; }
   int getC() { return this.c; }
   public void sum(int m, int n) {
       this.a = m; this.b = n;
       this.c = m + n;
   }
}
Описание слайда:
Getters and Setters can be Complex public class Sum { private int a, b, c; void setA(int m) { this.a = m; c = a + b; } void setB(int n) { this.b = n; c = a + b; } int getA() { return this.a; } int getB() { return this.b; } int getC() { return this.c; } public void sum(int m, int n) { this.a = m; this.b = n; this.c = m + n; } }

Слайд 16





Keyword "this"
this always points to current object
can't lose context like JavaScript
not required in most cases
often needed to distinguish between parameters and fields:
Описание слайда:
Keyword "this" this always points to current object can't lose context like JavaScript not required in most cases often needed to distinguish between parameters and fields:

Слайд 17





Keyword 'static'
Keyword 'static' indicates that some class member (method or field) is not associated with any particular object
Static members should be accessible by class name (good practice, not required by language itself)
Описание слайда:
Keyword 'static' Keyword 'static' indicates that some class member (method or field) is not associated with any particular object Static members should be accessible by class name (good practice, not required by language itself)

Слайд 18





Keyword 'static'
Описание слайда:
Keyword 'static'

Слайд 19





Constructors
Constructors – special kind of methods called when instance created
Name should be same as a class
Class may have multiple overloaded constructors
If not provided any constructor, Java provides default parameterless empty constructor
Описание слайда:
Constructors Constructors – special kind of methods called when instance created Name should be same as a class Class may have multiple overloaded constructors If not provided any constructor, Java provides default parameterless empty constructor

Слайд 20





Constructors
Описание слайда:
Constructors

Слайд 21





Creating objects – new()
Student stud1 = new Student();
  stud1.setName(“Dmytro”);
  stud1.setAge(25);
Student stud2 = 
     new Student(“Olga”);
 stud2.setAge(24);
Student stud3 = 
     new Student(“Ivan”, 26);
int n = Student.count;
Описание слайда:
Creating objects – new() Student stud1 = new Student(); stud1.setName(“Dmytro”); stud1.setAge(25); Student stud2 = new Student(“Olga”); stud2.setAge(24); Student stud3 = new Student(“Ivan”, 26); int n = Student.count;

Слайд 22





Private constructor
Making constructor private will prevent creating instances of a class from other classes
Still allows creating instances inside static methods of the class
Описание слайда:
Private constructor Making constructor private will prevent creating instances of a class from other classes Still allows creating instances inside static methods of the class

Слайд 23





toString()
System.out.println(student);
		com.edu.Student@659e0bfd
@Override
public String toString() {
	return "Student 
	 [lastNname=" + lastNname + 
	   ", firstName=" + firstName + 
	   ", age=" + age + "]";
}
	
	Student [lastNname=Ivanov, firstName=Vasiy, age=22]
Описание слайда:
toString() System.out.println(student); com.edu.Student@659e0bfd @Override public String toString() { return "Student [lastNname=" + lastNname + ", firstName=" + firstName + ", age=" + age + "]"; } Student [lastNname=Ivanov, firstName=Vasiy, age=22]

Слайд 24





Example
Create Console Application project in Java.
Add class Student to the project.
Class Student should consists of
	two private fields: name and rating; 
	properties for access to these fields
	static field avgRating – average rating of all students
	default constructor and constructor with parameters 
	methods:
	betterStudent - to definite the better student (between two, return true or false)
	toString - to output information about student
	changeRating - to change the rating of student
In the method main() create 3 objects of Student type and input information about them.
Display the average and total rating of all student.
Описание слайда:
Example Create Console Application project in Java. Add class Student to the project. Class Student should consists of two private fields: name and rating; properties for access to these fields static field avgRating – average rating of all students default constructor and constructor with parameters methods: betterStudent - to definite the better student (between two, return true or false) toString - to output information about student changeRating - to change the rating of student In the method main() create 3 objects of Student type and input information about them. Display the average and total rating of all student.

Слайд 25





Practical task
Create Console Application project in Java.
Add class Employee to the project.
Class Employee should consists of
	three private fields: name, rate and hours; 
	static field totalSum
	properties for access to these fields;
	default constructor, constructor with 2 parameters (name and rate) and constructor with 3 parameters;
	methods:
salary - to calculate the salary of person (rate * hours)
toString - to output information about employee
changeRate - to change the rate of employee
bonuses – to calculate 10% from salary
In the method main() create 3 objects of Employee type. Input information about them. 
Display the total hours of all workers to screen
Описание слайда:
Practical task Create Console Application project in Java. Add class Employee to the project. Class Employee should consists of three private fields: name, rate and hours; static field totalSum properties for access to these fields; default constructor, constructor with 2 parameters (name and rate) and constructor with 3 parameters; methods: salary - to calculate the salary of person (rate * hours) toString - to output information about employee changeRate - to change the rate of employee bonuses – to calculate 10% from salary In the method main() create 3 objects of Employee type. Input information about them. Display the total hours of all workers to screen

Слайд 26





Homework
Create Console Application project in Java.
Add class Person to the project.
Class Person should consists of
two private fields: name and birthYear (the birthday year) 
properties for access to these fields
default constructor and constructor with 2 parameters 
methods:
age - to calculate the age of person
input - to input information about person
output - to output information about person
changeName - to change the name of person
In the method main() create 5 objects of Person type and input information about them.
Описание слайда:
Homework Create Console Application project in Java. Add class Person to the project. Class Person should consists of two private fields: name and birthYear (the birthday year) properties for access to these fields default constructor and constructor with 2 parameters methods: age - to calculate the age of person input - to input information about person output - to output information about person changeName - to change the name of person In the method main() create 5 objects of Person type and input information about them.

Слайд 27





UDEMY course "Java Tutorial for Complete Beginners": https://www.udemy.com/java-tutorial/
UDEMY course "Java Tutorial for Complete Beginners": https://www.udemy.com/java-tutorial/
Complete lessons 17-23:
Описание слайда:
UDEMY course "Java Tutorial for Complete Beginners": https://www.udemy.com/java-tutorial/ UDEMY course "Java Tutorial for Complete Beginners": https://www.udemy.com/java-tutorial/ Complete lessons 17-23:

Слайд 28





The end
Описание слайда:
The end



Похожие презентации
Mypresentation.ru
Загрузить презентацию