












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













Prepared By Dr Jamal Zraqo
Part 2 Object Oriented Programming Course Prepared by Dr Jamal Zaraqo
class Point { private int x; private int y; public Point(int x,int y) { this.x =x; this.y =y; } public int getX() { return x; } public void setX(int xValue) { x = (xValue >0)? xValue:0; } public int getY() { return y; } public void setY(int yValue) { y = (yValue >0)? yValue:0; } }
1- 14 class Animal{ String color="white"; } class Dog extends Animal{ String color="black"; void printColor(){ System.out.println(color);// prints color of Dog class System.out.println( super .color);// prints color of Animal class } } class TestSuper1{ public static void main(String args[]){ Dog d= new Dog(); d.printColor();
Abstract classes and methods are shown in italics font.
abstract class Bike{ abstract void run(); } class Honda4 extends Bike{ void run() {System.out.println("running safely");} public static void main(String args[]){ Bike obj = new Honda4(); obj.run(); } }