Chapter 3 : HelloWorld Program — I
Q.2: Identify the correct statement. Answer : A
Q.3: What will happen if a Java program by name of “ prg.ca” is compiled? Answer : A
Q.4: How to give single line comment ? Answer : A
Q.5: How to give multi-line comment ? Answer : C Q.6: What will happen if a Java program by name of “ Prg. java” is compiled ? Answer : B
Q.7: My Prg.java will compile to …………… file. Answer : A Q.8: Binary Java code is also called as …………. Answer : B Q.9: What will happen if a Java program by name “Prg.java” is compiled? Answer : C Q.10: …………. Method is the entry point in Java program. Answer : C Q.11: What is the output ?
class Program {
public static void main(String a){
system.out.println(“HelloWorld”);
}
}
Answer : A Q.12: Which of the following is the valid entry point in a java program ? Answer : A Q.13: What is the output ?
class Program {
public static void main(String[]a){
System.out.println(“HelloWorld”);
}
}
Answer : B Q.14: What is the output if the command line arguments are : Ram Hari ?
}
Answer : B Q.15: What is the output(when no command line arguments are passed)?
}
Answer : D Q.16: What is the output ?
}
Answer : D Q.17: Identify the correct signature of “main” method which acts as an entry point. Answer: A Q.18: What is the output if the command line arguments is : Ram ?
}
Answer : D Q.19: System class belongs to ………….. package. Answer : A Q.20: What is the output ?
}
Answer : B Q.21: Which of the following is the valid entry point in a java program? Answer: D Q.22: What is the output ?
public static void Main(String args[]) {
system.out.println(“ HelloWorld”);
}
}
Answer : B Q.23: What is the output ?
public static void main(String args[]) {
system.out.println(“ HelloWorld”);
}
}
Answer : B Q.24: “System.out” is an object of ………. class. Answer : B Q.25: What is the output if the command line arguments are : 10 20 ?
class Program {
public static void main(String args[]) {
int i = Integer.parseInt(args[0]);
int j = Integer.ParseInt(args[1]);
system.out.println(i+j);
}
}
Answer : A Q.26: What is the output if the command line arguments are : A B ?
class Program {
public static void main(String args[]) {
int i = Integer.parseInt(args[0]);
int j = Integer.ParseInt(args[1]);
system.out.println(“The sum is :”+(i+j));
}
}
Originally published at https://cdac-java-mcq.blogspot.com.