public class GeneralClass {
Version1Program version1=new Version2Program();
private Object test;
GeneralClass(Object test){
this.test=test;
}
void GenaralMethod(){
version1.PrintCommom3();
}
}
package Inheritance;
import java.math.BigDecimal;
public class Version1Program {
private String common1;
private String common2;
private BigDecimal common3;
@SuppressWarnings({ "unused", "rawtypes" })
private Class[] test;
Version1Program() {
common1="common1default";
common2="common2default";
common3=new BigDecimal(0);
}
Version1Program(String common1,String common2, BigDecimal common3){
this.common1=common1;
this.common2=common2;
this.common3=common3;
}
Version1Program(Class<?> test){
this(new Class []{test});
}
Version1Program(Class<?> test[]){
this.test=test;
}
Version1Program(String common2)
{
this(null,common2,null);
}
Version1Program(BigDecimal common3)
{
this(null,null,common3);
}
public void PrintCommom1() {
System.out.println(common1);
}
public void PrintCommom2() {
System.out.println(common2);
}
public void PrintCommom3() {
System.out.println(common3);
}
}
package Inheritance;
import java.math.BigDecimal;
public class Version2Program extends Version1Program{
private String common11;
private String common22;
private BigDecimal common33;
@SuppressWarnings({ "unused", "rawtypes" })
private Class[] array;
Version2Program() {
common11="common11default";
common22="common22default";
common33=new BigDecimal(00);
}
Version2Program(String common1,String common2, BigDecimal common3){
super(common1,common2,common3);
this.common11=common1;
this.common22=common2;
this.common33=common3;
}
Version2Program(String common11)
{
this(common11,null,null);
}
Version2Program(BigDecimal common33)
{
this(null,null,common33);
}
Version2Program(@SuppressWarnings("rawtypes") Class[] array){
this.array=array;
}
public void PrintCommom11() {
System.out.println(common11);
}
public void PrintCommom22() {
System.out.println(common22);
}
public void PrintCommom33() {
System.out.println(common33);
}
public void PrintCommom3() {
System.out.println("I love you ............");
}
}
package Inheritance;
import java.math.BigDecimal;
import org.junit.Test;
public class Main {
@Test
public void Method1() {
GeneralClass generalclass=new GeneralClass(new Object());
generalclass.GenaralMethod();
}
}
No comments:
Post a Comment