Abstract Class, Interface, Package

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Inheritance and Polymorphism CS180 Fall Definitions Inheritance – object oriented way to form new classes from pre-existing ones –Superclass The.
SE-1020 Dr. Mark L. Hornick 1 Inheritance and Polymorphism: Abstract Classes The “not quite” classes.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Polymorphism. Legal assignments Widening is legal Narrowing is illegal (unless you cast) class Test { public static void main(String args[]) { double.
Inheritance and Polymorphism Recitation 04/10/2009 CS 180 Department of Computer Science, Purdue University.
Inheritance Inheritance is the process of using features (both attributes and methods) from an existing class. The existing class is called the superclass.
LECTURE 07 Programming using C# Inheritance
1 Pertemuan 6 Object Oriented Programming Matakuliah: T0053/Web Programming Tahun: 2006 Versi: 2.
CMSC 202 Interfaces. 11/20102 Classes and Methods When a class defines its methods as public, it describes how the class user interacts with the method.
Java Programming Robert Chatley William Lee
Polymorphism & Interfaces
6 < > 99 8 = 8 Click mouse for next screen. Lesson 2.
Interfaces Need arising from software engineering –Disparate groups of programmers need to agree to a “contract” that spells out how their software interacts.
Object Oriented Programming: Java Edition By: Samuel Robinson.
Computer Science [3] Java Programming II - Laboratory Course Lab 1 + 2: Review inheritance & abstract Review inheritance & abstractPolymorphism Faculty.
Inheritance, Abstract & Interface Pepper With help from and
Inheritence Put classes into a hierarchy derive a new class based on an existing class with modifications or extensions. Avoiding duplication and redundancy.
Inheritance Inheritance is the process of using features (both attributes and methods) from an existing class. The existing class is called the superclass.
28-Dec-04polymorhism.ppt1 Polymorphism. 28-Dec-04polymorhism.ppt2 signatures in any programming language, a signature is what distinguishes one function.
Classes. Student class We are tasked with creating a class for objects that store data about students. We first want to consider what is needed for the.
1 Chapter 9a Abstract Classes & Dynamic Binding. 2 Abstract Classes All classes so far have been concrete classes –Classes that can be used to create.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Interfaces and Polymorphism CS 162 (Summer 2009).
1 Inheritance and Subclasses. 2 Inheritance Often we create very similar classes –Different types of triangles: equilateral, isosceles, etc. –Different.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
CH10 Supplementary Material Prepared by Fatimah Alakeel Oct 2010.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Java Collection Classes Com379PT
Subtying Kangwon National University 임현승 Programming Languages These slides were originally created by Prof. Sungwoo Park at POSTECH.
Tutorial 2 Shane Paul. Contact Details Shane Paul Rm: 378 Ext: 82766
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Modern Programming Tools And Techniques-I
OBJECT ORIENTED PROGRAMMING
Web Design & Development Lecture 9
using System; namespace Demo01 { class Program
Interfaces.
Interfaces.
Interface.
What do cats eat ? They eat … 2A : Unit 8.
Java Interfaces & Abstract Classes
Week 8 Lecture -3 Inheritance and Polymorphism
OOP’S Concepts in C#.Net
More on Classes & Arrays
More inheritance, Abstract Classes and Interfaces
null, true, and false are also reserved.
Interface.
Interface & Inner classes
CMSC 202 Interfaces.
Introduction to Java Programming
Encapsulation and Constructors
Object-Oriented Programming
CS18000: Problem Solving and Object-Oriented Programming
Code Animation Examples
Method Overriding in Java
Recursive GCD Demo public class Euclid {
مظفر بگ محمدی دانشگاه ایلام
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
CMSC 202 Interfaces.
Interfaces and Abstract Classes
Chapter 9 Carrano Chapter 10 Small Java
Sampath Kumar S Assistant Professor, SECE
What is the "animal " doing ?.
Chapter 11 Inheritance and Encapsulation and Polymorphism
Topics OOP Review Inheritance Review Abstract Classes
CMSC 202 Interfaces.
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
INTERFACES Explained By: Sarbjit Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Presentation transcript:

Abstract Class, Interface, Package

Membuat sebuah project yang mengimplementasikan interface dan abstract class, dengan rincian sbb Abstract Class Animal Interface Flyer Interface Speaker Class Dog : extends Animal and implements Speaker Class Cat : extends Animal and implements Speaker Class Bird : extends Animal and implements Speaker, Flyer Class Bat : extends Animal and implements Flyer Main.java (main class)

<<abstract>> Animal <<abstract>> Dog Cat Bird Bat Interface : Flyer Interface : Speaker

Class Animal public abstract class Animal { private int age; public void setAge(int newAge) this.age=newAge; } public int getAge() return age; public abstract void eat() ; public abstract void walk();

Interface Flyer public interface Flyer { public void flying(); }

Class Cat public class Cat extends Animal implements Speaker { String name; public Cat(String newName) this.name=newName; } @Override public void eat() { System.out.println(name+" eat fish"); public void walk() { System.out.println(name+" with four leg"); public void speaking() { System.out.println(name+" speaks MIAUW MIAUW");

Class Main public class Main{ public static void main(String[] args) { Cat caty=new Cat("Caty"); caty.setAge(2); System.out.println("Caty's age is "+caty.getAge()+" years "); caty.eat(); caty.speaking(); }

Lengkapi pada project di atas Interface Speaker Class Dog Class Bird Class Bat