Академический Документы
Профессиональный Документы
Культура Документы
class Clock{ int minute; int hour; public Clock(int minute, int hour){ this.minute = minute; this.hour = hour; } } public class Cuckoo_Clock extends Clock{ public Cuckoo_Clock(int minute, int hour){ this.minute = minute; this.hour = hour; } public static void main(String[] args){ Cuckoo_Clock c = new Cuckoo_Clock(4, 3); } }
interface Cookable extends Edible{ public int cookTime(int e); public String dishName(int e); }
interface Compostable extends Edible{ public Edible compost(int c); } public class TrickInterfaces implements Cookable{ }
4)Whats the output for each line of main ? What are the static and dynamic types of all the object on each line of main?
class pipe{ int level = 1; public int carry(int b){ return b; } public int getLevel(){ return level; } } class tube extends pipe{ int level = 2; public int carry(int a){ return level + a; } public int getLevel(){ return level; } public int TubePressure(){ return 10282; } } public class Shadowing{ public static void main(String[] args){ tube t = new tube(); System.out.println(t.carry(10)); pipe p = (pipe)t; System.out.println(p.carry(10)); p.level = 50; System.out.println(p.carry(10)); System.out.println(p.level); System.out.println(p.getLevel()); } }