CSE 115 Lecture Notes - Lecture 28: Abstract Type, Instance Variable, Subtyping
Document Summary
What is wrong with this code? package noninheritance; package noninheritance; public class cat implements noisy { public class dog implements noisy { private string _myname; private string _myname; public cat(string n) { @override public string sound() { return meow ; public dog(string n) { _myname = n; public string getname() { return _myname; Inheritance is a relationship between two classes or two interfaces; it is syntactically simple but conceptually messy. In code: public abstract class noisy { } public class cat extends noisy { } public class dog extends noisy { } A class that mixes method specification (abstract methods) with fully defined methods (concrete methods) is abstract. An interface contains only abstract methods (they are labelled abstract" implicitly so you won"t necessarily see. An abstract class must have the abstract" keyword in the class header. Like an interface, an abstract can"t be instantiated.