Question 1 of 25
Hints left: 3
Q1
Arrays in Java are implemented as?
Q2
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); } }
Q3
Which class allows parsing of command line arguments?
Q4
What will be the output of the following Java code snippet run as $ java Demo -length 512 -breadth 2 -h 3? class Demo { @Parameter(names={"--length"}) int length; @Parameter(names={"--breadth"}) int breadth; @Parameter(names={"--height","-h"}) int height; public static void main(String args[]) { Demo demo = new Demo(); new JCommander(demo, args); demo.run(); } public void run() { System.out.println(length+" "+ breadth+" "+height); } }
Q5
Which of these is the method which is executed first before execution of any other thing takes place in a program?
Q6
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]+""); } } }
Q7
Which of these can be used to differentiate two or more methods having the same name?
Q8
Which one of the following is not an access modifier?
Q9
Which is the modifier when there is none mentioned explicitly?
Q10
What will be the output of the following Java program? class Output { static void main(String args[]) { int x , y = 1; x = 10; if(x != 10 && x / 0 == 0) System.out.println(y); else System.out.println(++y); } }
Q11
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.length()); } }
Q12
Which of these keywords is used to prevent content of a variable from being modified?
Q13
Which of the following statements are incorrect?
Q14
What will be the output of the following Java program? class string_demo { public static void main(String args[]) { String obj = "I" + "like" + "Java"; System.out.println(obj); } }
Q15
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); } }
Q16
Can command line arguments be converted into int automatically if required?
Q17
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); } }
Q18
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)); } }
Q19
Which of the following statements are incorrect?
Q20
Which annotation is used to represent command line input and assigned to correct data type?
Q21
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)); } }
Q22
What will be the output of the following Java program, Command line exceution is done as - "java Output This is a command Line"? class Output { public static void main(String args[]) { System.out.print(args[3]); } }
Q23
What will be the output of the following Java program? class box { int width; int height; int length; int volume; void volume() { volume = width * height * length; } void volume(int x) { volume = x; } } class Output { public static void main(String args[]) { box obj = new box(); obj.height = 1; obj.length = 5; obj.width = 5; obj.volume(5); System.out.println(obj.volume); } }
Q24
How many arguments can be passed to main()?
Q25
How do we pass command line argument in Eclipse?