Interview Question
Interview Question
8. Can you call the base class method without creating an instance?
1. Which kind of switch will be developing by the compiler while compiling the
following code?
class B
int i = 5;
switch(i)
{
case 3:
System.out.println("from case3");
break;
case 5:
System.out.println("from case5");
break;
case 6:
System.out.println("from case6");
break;
case 8:
System.out.println("from case8");
break;
6. class E
{
int i = 0;
if(i++ == 1)
System.out.println(i);
i += 7;
System.out.println(i);
i += 9;
else if(i++ == 2)
{
System.out.println(i);
i += 11;
System.out.println(i);
543212345
654323456
765434567
876545678
987656789
Use only one outer and one inner loop. Don’t use any extra variables apart from loop
indexes
class A{
A(){
System.out.println("A()");
A(int i){
this();
System.out.println("A(int)");
class B extends A{
B(){
super(90);
System.out.println("B()");
B(int i) {
System.out.println("B(int)");
}
}
class I {
A a1 = new A();
System.out.println("---------------");
A a2 = new A(10);
System.out.println("---------------");
B b1 = new B();
System.out.println("---------------");
B b2 = new B(10);
System.out.println("---------------");
...................
class D
int a = 50;
D(int i)
a = j;
D d1 = new D();
System.out.println(d1.a);
34.
class A
int i = 90;
String s1 = Integer.toBinaryString(i);
System.out.println(s1);
}
Input 10
Output 3,7
1. Given n pairs of parentheses, write a function to generate and return all combinations
of well-formed parentheses.
Input : 3
Output :
"((()))",
"(()())",
"(())()"
"()(())",
“()()()”
]