81. What will be the output of the following Java program?
class string_class
{
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.charAt(3));
}
}
class string_class
{
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.charAt(3));
}
}
82. Which annotation is used to represent command line input and assigned to correct data type?
83. What will be the output of the following Java 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);
}
}
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);
}
}
84. What will be the output of the following Java snippet, if compiled and executed with command line argument "java abc 1 2 3"?
public class abc
{
static public void main(String [] xyz)
{
for(int n=1;n<xyz.length; n++)
{
System.out.println(xyz[n]+"");
}
}
}
public class abc
{
static public void main(String [] xyz)
{
for(int n=1;n<xyz.length; n++)
{
System.out.println(xyz[n]+"");
}
}
}
85. Can command line arguments be converted into int automatically if required?
86. What will be the output of the following Java program?
class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = obj;
obj2 = " world";
System.out.println(obj + " " + obj2);
}
}
class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = obj;
obj2 = " world";
System.out.println(obj + " " + obj2);
}
}
87. What will be the output of the following Java program?
class area
{
int width;
int length;
int height;
area()
{
width = 5;
length = 6;
height = 1;
}
void volume()
{
volume = width * height * length;
}
}
class cons_method
{
public static void main(String args[])
{
area obj = new area();
obj.volume();
System.out.println(obj.volume);
}
}
class area
{
int width;
int length;
int height;
area()
{
width = 5;
length = 6;
height = 1;
}
void volume()
{
volume = width * height * length;
}
}
class cons_method
{
public static void main(String args[])
{
area obj = new area();
obj.volume();
System.out.println(obj.volume);
}
}
88. Arrays in Java are implemented as?
89. Which class allows parsing of command line arguments?
90. What will be the output of the following Java program?
class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = "hello";
System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));
}
}
class string_class
{
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = "hello";
System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));
}
}
Read More Section(Miscellaneous in Java)
Each Section contains maximum 100 MCQs question on Miscellaneous in Java. To get more questions visit other sections.