🗊Презентация Classes. Interfaces. Inheritance

Нажмите для полного просмотра!
Classes. Interfaces. Inheritance, слайд №1Classes. Interfaces. Inheritance, слайд №2Classes. Interfaces. Inheritance, слайд №3Classes. Interfaces. Inheritance, слайд №4Classes. Interfaces. Inheritance, слайд №5Classes. Interfaces. Inheritance, слайд №6Classes. Interfaces. Inheritance, слайд №7Classes. Interfaces. Inheritance, слайд №8Classes. Interfaces. Inheritance, слайд №9Classes. Interfaces. Inheritance, слайд №10Classes. Interfaces. Inheritance, слайд №11Classes. Interfaces. Inheritance, слайд №12Classes. Interfaces. Inheritance, слайд №13Classes. Interfaces. Inheritance, слайд №14Classes. Interfaces. Inheritance, слайд №15Classes. Interfaces. Inheritance, слайд №16Classes. Interfaces. Inheritance, слайд №17Classes. Interfaces. Inheritance, слайд №18Classes. Interfaces. Inheritance, слайд №19Classes. Interfaces. Inheritance, слайд №20Classes. Interfaces. Inheritance, слайд №21Classes. Interfaces. Inheritance, слайд №22Classes. Interfaces. Inheritance, слайд №23

Вы можете ознакомиться и скачать презентацию на тему Classes. Interfaces. Inheritance. Доклад-сообщение содержит 23 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

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


Слайд 1





Java. Inheritance

IT Academy
Описание слайда:
Java. Inheritance IT Academy

Слайд 2





Agenda
Classes. Interfaces. Abstract Classes
Inheritance in Java
Polymorphism
Java Classes. Examples
Описание слайда:
Agenda Classes. Interfaces. Abstract Classes Inheritance in Java Polymorphism Java Classes. Examples

Слайд 3





Abstract Classes
A class must be declared abstract when it has one or more abstract methods.
A method is declared abstract when it has a method heading, but no body – which means that an abstract method has no implementation code inside curly braces like normal methods do.
The derived class must provide a definition method;
The derived class must be declared abstract itself. 
A non abstract class is called a concrete class.
Описание слайда:
Abstract Classes A class must be declared abstract when it has one or more abstract methods. A method is declared abstract when it has a method heading, but no body – which means that an abstract method has no implementation code inside curly braces like normal methods do. The derived class must provide a definition method; The derived class must be declared abstract itself. A non abstract class is called a concrete class.

Слайд 4





Abstract Classes
	/* The Figure class must be declared as abstract because it contains an abstract method */
	public abstract class Figure {
	/* because this is an abstract method the body will be blank */
		public abstract double getArea();
	}
	public class Circle extends Figure {
		private double radius;
		public Circle (double radius) {
			this.radius = radius;
		public double getArea() {
			return (3.14 * (radius * 2));   }   }
Описание слайда:
Abstract Classes /* The Figure class must be declared as abstract because it contains an abstract method */ public abstract class Figure { /* because this is an abstract method the body will be blank */ public abstract double getArea(); } public class Circle extends Figure { private double radius; public Circle (double radius) { this.radius = radius; public double getArea() { return (3.14 * (radius * 2)); } }

Слайд 5





Classes. Abstract Classes
	public class Rectangle extends Figure {
		private double length, width;
		//
		public Rectangle(double length, double width) {
			this.length = lengt;
			this.width = width;
		}
		//
		public double getArea() {
			return length * width;
		}
	}
Описание слайда:
Classes. Abstract Classes public class Rectangle extends Figure { private double length, width; // public Rectangle(double length, double width) { this.length = lengt; this.width = width; } // public double getArea() { return length * width; } }

Слайд 6





Interfaces
An interface differs from an abstract class because an interface is not a class.
An interface is essentially a type that can be satisfied by any class that implements the interface. 
Any class that implements an interface must satisfy 2 conditions
It must have the phrase "implements Interface_Name" at the beginning of the class definiton;
It must implement all of the method headings listed in the interface definition.
Описание слайда:
Interfaces An interface differs from an abstract class because an interface is not a class. An interface is essentially a type that can be satisfied by any class that implements the interface. Any class that implements an interface must satisfy 2 conditions It must have the phrase "implements Interface_Name" at the beginning of the class definiton; It must implement all of the method headings listed in the interface definition.

Слайд 7





Interfaces
	public interface Dog {
		public boolean Barks();
		public boolean isGoldenRetriever();
	}
	public class SomeClass implements Dog {
		public boolean Barks() {
			// method definition here
		}
		public boolean isGoldenRetriever() {
			// method definition here
		}
	}
Описание слайда:
Interfaces public interface Dog { public boolean Barks(); public boolean isGoldenRetriever(); } public class SomeClass implements Dog { public boolean Barks() { // method definition here } public boolean isGoldenRetriever() { // method definition here } }

Слайд 8





Inheritance in Java
Assignment operator. What will be done ?
	int num=1;
	double data=1.0;
	data=num;  //  num=data; ???
	class Aclass {
 	    int field1=10; 
	}
	class Bclass extends Aclass {
 	    int field2=20;
	}
	Aclass a=new Aclass( );
	Bclass b=new Bclass( );
	a=b;  //  b=a; ???           // a = new Bclass( );
Описание слайда:
Inheritance in Java Assignment operator. What will be done ? int num=1; double data=1.0; data=num; // num=data; ??? class Aclass { int field1=10; } class Bclass extends Aclass { int field2=20; } Aclass a=new Aclass( ); Bclass b=new Bclass( ); a=b; // b=a; ??? // a = new Bclass( );

Слайд 9





Inheritance in Java
	public class ClassA {
	    public int i=1;
	    public void m1() {
		System.out.println("ClassA, metod m1, i="+i);  }
	    public void m2() {
		System.out.println("ClassA, metod m2, i="+i);  }
	    public void m3() {
	    	System.out.print("ClassA, metod m3, runnind m4(): ");
		m4();  }
 	    public void m4() {
 		System.out.println("ClassA, metod m4");
	}   }
Описание слайда:
Inheritance in Java public class ClassA { public int i=1; public void m1() { System.out.println("ClassA, metod m1, i="+i); } public void m2() { System.out.println("ClassA, metod m2, i="+i); } public void m3() { System.out.print("ClassA, metod m3, runnind m4(): "); m4(); } public void m4() { System.out.println("ClassA, metod m4"); } }

Слайд 10





Inheritance in Java
	public class ClassB extends ClassA {
	    public double i=1.1;
	    public void m1() {
		System.out.println("ClassB, metod m1, i="+i);
	    }
	    public void m4() {
		System.out.println("ClassB, metod m4");
	    }
	}
Automatically added default constructor.
Описание слайда:
Inheritance in Java public class ClassB extends ClassA { public double i=1.1; public void m1() { System.out.println("ClassB, metod m1, i="+i); } public void m4() { System.out.println("ClassB, metod m4"); } } Automatically added default constructor.

Слайд 11





Inheritance in Java
	public class ApplAB {
	public static void main(String[] args) {
	    System.out.println("The Start.");
	    ClassA a;
	    ClassA b;
	    a=new ClassA();
	    b=new ClassB();
	    System.out.println("Test ClassA.");
	    a.m1();
	    a.m2();
	    a.m3();
	    a.m4();
Описание слайда:
Inheritance in Java public class ApplAB { public static void main(String[] args) { System.out.println("The Start."); ClassA a; ClassA b; a=new ClassA(); b=new ClassB(); System.out.println("Test ClassA."); a.m1(); a.m2(); a.m3(); a.m4();

Слайд 12





Inheritance in Java
	    System.out.println("Test ClassB.");
	    b.m1();
	    b.m2();
	    b.m3();
	    b.m4();
	    ClassB b0;
	    b0=new ClassB();
	    System.out.println("Test_0 ClassB.");
	    b0.m1();
	    b0.m2();
	    b0.m3();
	    b0.m4();
	    System.out.println("The End.");  }  }
Описание слайда:
Inheritance in Java System.out.println("Test ClassB."); b.m1(); b.m2(); b.m3(); b.m4(); ClassB b0; b0=new ClassB(); System.out.println("Test_0 ClassB."); b0.m1(); b0.m2(); b0.m3(); b0.m4(); System.out.println("The End."); } }

Слайд 13





Inheritance in Java
The Start.
Test ClassA.
ClassA, metod m1, i=1
ClassA, metod m2, i=1
ClassA, metod m3, runnind m4(): ClassA, metod m4
ClassA, metod m4
Test ClassB.
ClassB, metod m1, i=1.1
ClassA, metod m2, i=1
ClassA, metod m3, runnind m4(): ClassB, metod m4
ClassB, metod m4
Test_0 ClassB.
ClassB, metod m1, i=1.1
ClassA, metod m2, i=1
ClassA, metod m3, runnind m4(): ClassB, metod m4
ClassB, metod m4
The End.
Описание слайда:
Inheritance in Java The Start. Test ClassA. ClassA, metod m1, i=1 ClassA, metod m2, i=1 ClassA, metod m3, runnind m4(): ClassA, metod m4 ClassA, metod m4 Test ClassB. ClassB, metod m1, i=1.1 ClassA, metod m2, i=1 ClassA, metod m3, runnind m4(): ClassB, metod m4 ClassB, metod m4 Test_0 ClassB. ClassB, metod m1, i=1.1 ClassA, metod m2, i=1 ClassA, metod m3, runnind m4(): ClassB, metod m4 ClassB, metod m4 The End.

Слайд 14





Polymorphism
package com.softserve.train;
public abstract class ACar {
    private double maxSpeed;
    public double getMaxSpeed( ) {
        return maxSpeed;
    }
    public void setMaxSpeed(double maxSpeed) {
        this.maxSpeed = maxSpeed;
    }
    abstract void carRides( );
}
Описание слайда:
Polymorphism package com.softserve.train; public abstract class ACar { private double maxSpeed; public double getMaxSpeed( ) { return maxSpeed; } public void setMaxSpeed(double maxSpeed) { this.maxSpeed = maxSpeed; } abstract void carRides( ); }

Слайд 15





Polymorphism
public class BmwX6 extends ACar {
   public BmwX6( ) { }
   @Override
    public void carRides( ) {
        setMaxSpeed(200);
        System.out.println("Car Rides");
        workedEngine( );
        workedGearBox( );
    }
    public void workedEngine( ) {
        System.out.println("BmwX6: Engine Running on Petrol.");
        System.out.println("BmwX6: Max Speed: " +
                                        getMaxSpeed( ));
    }
Описание слайда:
Polymorphism public class BmwX6 extends ACar { public BmwX6( ) { } @Override public void carRides( ) { setMaxSpeed(200); System.out.println("Car Rides"); workedEngine( ); workedGearBox( ); } public void workedEngine( ) { System.out.println("BmwX6: Engine Running on Petrol."); System.out.println("BmwX6: Max Speed: " + getMaxSpeed( )); }

Слайд 16





Polymorphism
 private void workedGearBox( ) {
        System.out.println("BmwX6: Worked GearBox.");
    }
    public void lightsShine( ) {
        System.out.println("BmwX6: Halogen Headlights.");
    }
}
inheritance of private fields and methods ?
Описание слайда:
Polymorphism private void workedGearBox( ) { System.out.println("BmwX6: Worked GearBox."); } public void lightsShine( ) { System.out.println("BmwX6: Halogen Headlights."); } } inheritance of private fields and methods ?

Слайд 17





Polymorphism
package com.softserve.train;
public class BmwX6mod extends BmwX6 {
    public BmwX6mod( ) {
        super( );
    }
   @Override
    public void workedEngine( ) {
        System.out.println("BmwX6mod:
                                       Engine Running on Diesel.");
        System.out.println("BmwX6mod: Max Speed: " +
                                       getMaxSpeed( ));
    }
   @Override
    public void lightsShine( ) {
        System.out.println("BmwX6mod: Xenon Headlights.");
        super.lightsShine();
    }
}
Описание слайда:
Polymorphism package com.softserve.train; public class BmwX6mod extends BmwX6 { public BmwX6mod( ) { super( ); } @Override public void workedEngine( ) { System.out.println("BmwX6mod: Engine Running on Diesel."); System.out.println("BmwX6mod: Max Speed: " + getMaxSpeed( )); } @Override public void lightsShine( ) { System.out.println("BmwX6mod: Xenon Headlights."); super.lightsShine(); } }

Слайд 18





Polymorphism
package com.softserve.train;
public class Appl {
    public static void main(String[ ] args) {
        ACar carX6 = new BmwX6( );
        ACar carX6mod = new BmwX6mod( );
        BmwX6 carX6mod2 = new BmwX6mod( );
        carX6.carRides( );
        ((BmwX6)carX6).lightsShine( );
        carX6mod.carRides( );
        ((BmwX6)carX6mod).lightsShine( );
        carX6mod2.carRides( );
        carX6mod2.lightsShine( );
    }
}
Описание слайда:
Polymorphism package com.softserve.train; public class Appl { public static void main(String[ ] args) { ACar carX6 = new BmwX6( ); ACar carX6mod = new BmwX6mod( ); BmwX6 carX6mod2 = new BmwX6mod( ); carX6.carRides( ); ((BmwX6)carX6).lightsShine( ); carX6mod.carRides( ); ((BmwX6)carX6mod).lightsShine( ); carX6mod2.carRides( ); carX6mod2.lightsShine( ); } }

Слайд 19





Java Classes
What is wrong in the code ?

package com.softserve.train;
public class Parent {
    int f( ) {
        return 1;
    }
}
public int f( ) { …		 what will in case ???
Описание слайда:
Java Classes What is wrong in the code ? package com.softserve.train; public class Parent { int f( ) { return 1; } } public int f( ) { … what will in case ???

Слайд 20





Java Classes
package com.softserve.train2;
import com.softserve.train.Parent;
public class Child extends com.softserve.train.Parent {
    int f( ) {
        return 2;
    }
}
protected int f( ) { …		 what will in case ???
Описание слайда:
Java Classes package com.softserve.train2; import com.softserve.train.Parent; public class Child extends com.softserve.train.Parent { int f( ) { return 2; } } protected int f( ) { … what will in case ???

Слайд 21





Java Classes
package com.softserve.train;
import com.softserve.train2.Child;
public class Grandchild extends com.softserve.train2.Child {
    public int y( ) {
        return this.f( ); // ???
    }
}
Описание слайда:
Java Classes package com.softserve.train; import com.softserve.train2.Child; public class Grandchild extends com.softserve.train2.Child { public int y( ) { return this.f( ); // ??? } }

Слайд 22





Java Classes
package com.softserve.train;
public class Appl {
    public static void main(String[] args) {
        Grandchild g = new Grandchild();
        boolean result = (g.f( ) == g.y( ));   // ???
        System.out.println("result=" + result);
    }
}
Описание слайда:
Java Classes package com.softserve.train; public class Appl { public static void main(String[] args) { Grandchild g = new Grandchild(); boolean result = (g.f( ) == g.y( )); // ??? System.out.println("result=" + result); } }

Слайд 23


Classes. Interfaces. Inheritance, слайд №23
Описание слайда:



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