8 Discussion / Question Topics
Remove Filter
|
|
Please bear with me, this is my first post So, I have this superclass called A. And I've 2 subclasses A1 and A2. A has attribute name. A has function toString(). A1 inherits name, and has attribute hair. A1 has a method toString() which goes: string A1::toString(){ string stringA= A::toString(); … |
|
<? super Animal> means animal or it's superclass only. Then why inside the method it's allowing to add Dog object even though it's a subclass of Animal? This program compiles and runs! import java.util.*; class Cat {} class Animal{Animal() {System.out.println("Animal constructor");}} class Dog extends Animal{Dog() {System.out.println("Dog constructor");}} public class GenericDemo5 … |
|
General rules is that: 1) A private method cannot be overridden. 2) Subclass method should be a lower access modifier than a overridden superclass method. But the output of the program is "I am Son". Why? Is it because of the rule 2 the output comes? If that's the case … |
|
Hi Can any one tell me how to call a subclass method from a superclass? For example: I have a class A,B and C. Now B and C extends A. So is there any way that we can call a method of B in A? Thanks Abhishek |
|
I'm getting a mismatch error and I've looked up why it would appear and I'm confused because what I'm doing doesn't match the error cause. Plus I've followed the instructions from a guide that I'm using. The code on irb... >> class Cat >> attr_accessor :name, :age, :gender >> end … |
|
Basically this program uses an abstract class which 3 other classes extends to so that in the end an overridden toString() method will print out how many pages must be read for each class. Okay, well this program is for a class, but I am kinda of stuck because my … |
|
Hi there. I am currently trying to get my head around using classes across two files. I currently have a super class and a sub class stored in a file and the main function in another. When I try and pass arguments to the class they work fine if the … |
|
Hello folks I'm trying to do my assignment and I'm really stuck in! I have to classes..Customer and Pensioner (Customer = Super class and Pensioner = Subclass) The Pensioner has a PensionNo extra than Customer class. I have to make a array of Customer class (for 10) and put Customer … |
The End.