L2 round questions -
1) Find error in below code -
class Base
{
final public void show()
{
System.out.println("Base:test() call");
}
}
class Derived extends Base
{
public void show()
{
System.out.println("Derived:test() call");
}
}
class Main
{
public static void main(String[] args)
{
Base b = new Derived();
b.show();
}
}
2) Write code for equivalent star pattern in java
3) Write code to identify all the numbers in this array whose sum is also present in the array
sample array 1 = [-1, 3, -2, 1, -4, 0, 5, 2, -3]
sample array 2 = [21, 13, 47, 61, 34, 40, 55, 71, 87]
example =
-1 + 3 = 2 (also present in array so will be printed)
-4 + 0 = -4 (not present in array so will be excluded)