Which of these keywords is used to prevent content of a variable from being modified?
Which of these cannot be declared static?
Which of these methods must be made static?
What is the output of this program?
class access{
public int x;
static int y;
void cal(int a, int b){
x += a ;
y += b;
}
}
class static_specifier {
public static void main(String args[]){
access obj1 = new access();
access obj2 = new access();
obj1.x = 0;
obj1.y = 0;
obj1.cal(1, 2);
obj2.x = 0;
obj2.cal(2, 3);
System.out.println(obj1.x + " " + obj2.y);
}
}
What is the output of this program?
class access{
static int x;
void increment(){
x++;
}
}
class static_use {
public static void main(String args[]){
access obj1 = new access();
access obj2 = new access();
obj1.x = 0;
obj1.increment();
obj2.increment();
System.out.println(obj1.x + " " + obj2.x);
}
}
What is the output of this program?
class Output {
public static void main(String args[]){
int arr[] = {1, 2, 3, 4, 5};
for ( int i = 0; i < arr.length - 2; ++i)
System.out.println(arr[i] + " ");
}
}
String in Java is a?
Which of these method of String class is used to obtain character at specified index?
Which of these keywords is used to refer to member of base class from a sub class?
Which of these method of String class can be used to test to strings for equality?
What is the output of this program?
class string_demo {
public static void main(String args[]){
String obj = "I" + "like" + "Java";
System.out.println(obj);
}
}
What is the output of this program?
class string_class {
public static void main(String args[]){
String obj = "I LIKE JAVA";
System.out.println(obj.charAt(3));
}
}
What is the output of this program?
class string_class {
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.length());
}
}