JAVA MCQS PART 2 FOR UGC
NET COMPUTER SCIENCE
1. Predict the output:
public class Cdac
{
public static void main(String args[])
{
String s1="sun";
System.out.println(s1.substring(2));
}
}
A.
-1
B.
0
C.
ArrayIndexOutOfBoundsException
D.
StringIndexOutOfBoundsException
Ans.: D
2. Which of the following modifier
can be applied to a constructor.
A.
Private
B.
Abstract
C.
public
D.
All of the above
Ans.: c
3. Inner classes cannot declare ------------ variables.
A.
Protected
B.
Final
C.
Static
D.
Transient
Ans.: D