Questions tagged [single-inheritance]
8 questions
2
votes
0 answers
Is it possible to use TestNG with Spring Test without extending AbstractTestNGSpringContextTests?
I'm trying to refactor our testing framework to use TestNG rather than JUnit, and to do this we need to replace our pre-existing JUnit code with a TestNG equivalent. While it provides additional benefits and extensible functionality over JUnit in…

user3466773
- 176
- 1
- 2
- 14
0
votes
1 answer
Single Inheritance output question in java
I have a output question in java.
package javaapplication32;
class Animal {
String name = "Animal";
Animal() {
System.out.println("Animal's name is: " + getName());
}
String getName() {
return name;
}
}
class…

isofiso
- 1
- 2
0
votes
2 answers
Accessing private member of base class using derived class member function
I have just started learning about inheritance and I know that private members of base class are not inherited by the derived class.
But when I run the 'get_data1' function of the derived class, it returns the value of data1 from the base class even…

World Travellzzz
- 17
- 5
0
votes
2 answers
Can we use super method in a newly created class without any inheritance?
I am new to classes in python. I searched and went through so many articles on super() method which creates so much of confusion.
Type - 1
class Square():
def __init__(self,side):
self.side = side
print("Its confusing")
…

shaila
- 177
- 2
- 10
0
votes
0 answers
needed help in solving of inheritance problem in c++ problem
I have a C++ question regarding inheritance:
Write a program that has a class Train with data members seats_first_class, seats_second_class and seats_ac_2tier and member functions to set and display data.
Derive a class Reservation that has data…

pHeroXoc
- 31
- 5
0
votes
0 answers
Single Inheritance Empty Base Optimization Not Working on MSVC
Why is the following not working?
If sizeof(B) is 8, so sizeof(C) should also be 8 since it's inheriting from a single classe, EBO should've been still be used here.
Do I really have to use __declspec(empty_bases) here? :/
struct A {};
struct B : A…

João Pires
- 927
- 1
- 5
- 16
0
votes
2 answers
Why inheritance works this way in Java?
I'm new to Java and I'm trying to understand what would happen when I assign a child class instance to a parent class instance variable by simulating the following program.
public class ConfusionWithInheritance {
public static void…
user7665040
-2
votes
1 answer
Using instance of subclass I cannot access attributes of parent class
I have a subclass cal which inherits from read, but when I create an instance, I cannot access the parent attributes from the child's methods:
class read:
def __init__(self,p,t,r):
self.p = p
self.t = t
self.r = r
def…

c. chakrapani
- 3
- 2