Interview Questions on Java coding

1)what is the output?
String s="Test";
s=s.substring(1,1);
syso(s)

Ans: print nothing

2)String s="Test";
s.contains("");

Ans: True

3)what is the output?
String s="Test";
String k=s.concats(null);
sysout(k)

Ans: NullPointerException

4)what is the output?
String sp="Java String Split";
                String sp1[]=sp.split("\\s",1);
                
                System.out.println(sp1[0]);

Ans:Java String Split

5) how to print the 2nd table or any table of maths in SQL?
2*1=2
2*2=4
2*3=6
.....
.....
2*10=20
Ans:SELECT '2*'||to_char(level)||'='||to_char(2*LEVEL) FROM dual CONNECT BY LEVEL < 11




Share This

0 comments: