I know that the ternary operator in Java should return something. But I don't know what should I return while calling the constructor.
This is my code :
class Base
{
public Base(int a, int b)
{
System.out.println("Constructor of Dummy");
System.out.println("a: "+a);
System.out.println("b: "+b);
}
public Base(float a)
{
System.out.println("Constructor of Dummy");
System.out.println("a: "+a);
}
}
class Derived extends Base
{
public Derived(int c)
{
c%2==0 ? super(10,20) : super(1.4f);
}
}
class test
{
public static void main(String args[])
{
Derived d1 = new Derived(5);
}
}
Please answer if someone knows about it.