Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

single level inheritance in java

USING - C++

 Source Code

// Contributed by - Debojyoti Chakraborty ( GC College, Silchar - @ Department of Computer Science )
#include<iostream>
using namespace std;

class A {
	public:
		int x;
		void getData_A() {
			cout<<"Enter the value of X = ";
			cin>> x;
		}
};

//	Class-C derived from Class-A
class B : public A {
	public:
		int y;
		void getData_B() {
			cout<<"Enter the value of Y = ";
			cin>> y;
		}
};

//	Class-C derived from Class-B
class C : public B {
	public:
		int z;
		void getData_C() {
			cout<<"Enter the value of Z = ";
			cin>> z;
		}
		void showProduct() {
			cout<<"
The product of X, Y & Z is : "<< x * y * z;
		}
};

int main() {
	C obj;
	obj.getData_A();
	obj.getData_B();
	obj.getData_C();
	obj.showProduct();
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Java :: implement queue using array in java 
Java :: firestore java timestamp 
Java :: each loop in java 
Java :: java sort reverse lambda 
Java :: java startswith regex 
Java :: GridLayout 
Java :: java comparator comparing 
Java :: add string to array java 
Java :: void * to int 
Java :: c++ vs java 
Java :: what is return method 
Java :: method overloading 
Java :: android studio tabbed activity 
Java :: java print array of objects 
Java :: calling a void method java 
Java :: javafx combobox cell 
Java :: how to call the main method in java 
Java :: java exception handling 
Java :: teimpo en segundos java 
Java :: generate random color java 
Java :: android adb is using too much cpu 
Java :: java.lang.NullPointerException: Cannot store to double array because is null 
Java :: Copying value from one input field to another input field using checkbox 
Java :: null check in line java 
Java :: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 
Java :: netbeans how to get string from jcombobox 
Java :: Composite foreign keys as primary key jpa 
Java :: how to set up basic java workspace 
Java :: import txt.xz file to android studio app 
Java :: java datasource 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =