Содержание
- 2. AGENDA Java OOPs Concepts Interface Polymorphism Sorting *Class Diagram
- 3. Java OOPs Concepts Object Any entity that has state and behavior is known as an object.
- 4. Java OOPs Concepts Inheritance When one object acquires all the properties and behaviors of parent object
- 5. Interfaces An interface is a reference type in Java, it is similar to class, it is
- 6. Interfaces public interface Worker { int getSalary(); // public abstract } public class Director implements Worker
- 7. Interfaces Example interface Volumetric { double PI = 3.14; double getVolume(); static double getPI() { return
- 8. Interfaces To access the interface methods, the interface must be "implemented by another class with the
- 9. Multiple interfaces implementation To implement multiple interfaces, separate them with a comma: class Cube extends Shape
- 10. Interfaces with same method If a type implements two interfaces, and each interface define a method
- 11. Extending Interfaces An interface can extend another interface in the same way that a class can
- 12. Polymorphism Polymorphism is the concept, according to which a common interface used for data processing various
- 13. The instanceof Operator The instanceof operator allows you determine the type of an object. Shape shapes[]
- 14. Polymorphism public abstract class ACar { private double maxSpeed; public double getMaxSpeed( ) { return maxSpeed;
- 15. Polymorphism public class BmwX6 extends ACar { public BmwX6( ) { } @Override public void carRides(
- 16. Polymorphism public void workedEngine( ) { System.out.println("BmwX6: Engine Running on Petrol."); System.out.println("BmwX6: Max Speed: " +
- 17. Polymorphism public class BmwX6mod extends BmwX6 { public BmwX6mod( ) { super( ); } @Override public
- 18. Polymorphism public class Appl { public static void main(String[ ] args) { ACar carX6 = new
- 19. Sorting public static void main(String[] args) { int[] x = new int[10]; Random rand = new
- 20. Class Arrays. Sorting public static void main(String[ ] args) { Student[ ] students = new Student[3];
- 21. Compare elements To specify the order of the following interfaces: Comparable and Comparator public class MyType
- 22. Interface Comparable Interface Comparable allows custom sorting of objects when implemented. When a class implements this
- 23. Interface Comparable Example: Person people[] = { new Person("Bill", 34), new Person("Tom", 23), new Person("Alice", 21),
- 24. Interface Comparator Interface Comparator allows custom sorting of objects when implemented. When a class implements this
- 25. Example 1 public class Employee { int tabNumber; String name; public Employee(String name, int tabNumber) {
- 26. Example 1 import java.util.Comparator; public class NameComparator implements Comparator { @Override public int compare(Employee o1, Employee
- 27. Example 1 import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) {
- 28. Example 1 list.sort(new NameComparator()); for (Employee employee : list) { System.out.println(employee); } list.sort(new TabComparator()); for (Employee
- 29. Example 2 public class Employee { int tabNumber; String name; static NameComparator nameComparator = new NameComparator(
- 30. Example 2 static class NameComparator implements Comparator { public int compare(Object o1, Object o2) { return
- 31. Example 2 public static void main(String[] args) { Set set = new TreeSet(Employee.getNameComparator()); set.add(new Employee(15, "Vasya"));
- 32. Class Diagram. Visibility and scope
- 33. Class Diagram
- 34. Class Diagram Our class diagram has three kinds of relationships. association -- a relationship between instances
- 35. Class Diagram. Multiplicities
- 36. Composition and aggregation
- 37. Dependencies and constraints
- 38. Interfaces and stereotypes
- 39. final A final variable can only be assigned once and its value cannot be modified once
- 40. Practical tasks Create interface Animal with methods voice() and feed(). Create two classes Cat and Dog,
- 41. HomeWork (online course) UDEMY course "Java Tutorial for Complete Beginners": https://www.udemy.com/java-tutorial/ Complete lessons 26-31:
- 42. Homework Create Payment interface with the method calculatePay(), the base class Employee with a string variable
- 43. Homework The calculation formula for the "time-worker“ is: the average monthly salary = hourly rate *
- 44. Homework 2. Develop and test a program’s structure corresponding to the next schema
- 46. Скачать презентацию