Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
MyBirdClass
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; class Bird{ protected static int counter=0; protected String birdName; protected String bodyColor, beakColor; protected boolean canFly; public Bird(){ counter++;} public Bird(String bn, String bc, String bkc,boolean cf) { birdName=bn; bodyColor=bc; beakColor=bkc; canFly=cf; counter++; } public void fly(int height) { System.out.println("I am "+ birdName+" flying at "+ height+" feet high in the sky"); } public String getBirdName( ) { return birdName;} public static int getCount(){ return counter; } } class SingingBird extends Bird{ public SingingBird(String bn,String bc, String bkc, boolean cf) { super(bn,bc,bkc,cf); } } class Rextester { public static void main(String args[]) { Bird b1=new Bird("Parrot","Green","Red",true); b1.fly(200); SingingBird b2=new SingingBird("Ninghtingale","Black","White",true); b2.fly(300); Bird b3=new Bird(); System.out.println("Total number of birds "+Bird.getCount()); System.out.println("I am a "+b2.getBirdName()); } }
run
|
edit
|
history
|
help
0
queue_using_stack
Coding Challenge - 03 (Prime numbers)
// Java Coding Challenge - 09: Find out duplicate numbers using Array
String object comparision
Coding Challenge - 04 (Perfect numbers)
string reverse program without arry in java
상속1
Most Common Word
java palindrome check
JAVA # Dizi ile Fibonaççi