CSE 115 Lecture Notes - Lecture 28: Abstract Type, Instance Variable, Subtyping

35 views3 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents