Содержание
- 2. 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.
- 4. Abstract Classes /* The Figure class must be declared as abstract because it contains an abstract
- 5. Classes. Abstract Classes public class Rectangle extends Figure { private double length, width; // public Rectangle(double
- 6. Interfaces An interface differs from an abstract class because an interface is not a class. An
- 7. Interfaces public interface Dog { public boolean Barks(); public boolean isGoldenRetriever(); } public class SomeClass implements
- 8. Inheritance in Java Assignment operator. What will be done ? int num=1; double data=1.0; data=num; //
- 9. Inheritance in Java public class ClassA { public int i=1; public void m1() { System.out.println("ClassA, metod
- 10. Inheritance in Java public class ClassB extends ClassA { public double i=1.1; public void m1() {
- 11. Inheritance in Java public class ApplAB { public static void main(String[] args) { System.out.println("The Start."); ClassA
- 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();
- 13. Inheritance in Java The Start. Test ClassA. ClassA, metod m1, i=1 ClassA, metod m2, i=1 ClassA,
- 14. Polymorphism package com.softserve.train; public abstract class ACar { private double maxSpeed; public double getMaxSpeed( ) {
- 15. Polymorphism public class BmwX6 extends ACar { public BmwX6( ) { } @Override public void carRides(
- 16. Polymorphism private void workedGearBox( ) { System.out.println("BmwX6: Worked GearBox."); } public void lightsShine( ) { System.out.println("BmwX6:
- 17. Polymorphism package com.softserve.train; public class BmwX6mod extends BmwX6 { public BmwX6mod( ) { super( ); }
- 18. Polymorphism package com.softserve.train; public class Appl { public static void main(String[ ] args) { ACar carX6
- 19. Java Classes What is wrong in the code ? package com.softserve.train; public class Parent { int
- 20. Java Classes package com.softserve.train2; import com.softserve.train.Parent; public class Child extends com.softserve.train.Parent { int f( ) {
- 21. Java Classes package com.softserve.train; import com.softserve.train2.Child; public class Grandchild extends com.softserve.train2.Child { public int y( )
- 22. Java Classes package com.softserve.train; public class Appl { public static void main(String[] args) { Grandchild g
- 24. Скачать презентацию