Chapter 3 : HelloWorld Program – I

0

  HelloWorld Program – I


Q.1: What is the valid extension of a Java program ?

A. .Java
B. .JAVA
C. .JJ
D. None of these

 

Q.2: Identify the correct statement.

A. Java program file extension is case sensitive.
B. Java program file extension is case sensitive only on Mac OS.
C. Java program file extension is not case sensitive.
D. None of these

Answer : A

Q.3: What will happen if a Java program by name of ” prg.ca” is compiled?

A. Compiler error
B. No compiler error
C. Runtime error
D. None of the above

Answer : A

Q.4: How to give single line comment ?

A. //
B. #
C. ” ”
D. /

Answer : A

Q.5: How to give multi-line comment ?

A. //
B. #
C. /* …*/
D. ” ”

Answer : C

Q.6: What will happen if a Java program by name of ” Prg. java” is compiled ?

A. Runtime error
B. Compiler error
C. Data error
D. None of the above

Answer : B

Q.7: My Prg.java will compile to …………… file.

A. MyPrg.class
B. MyPrg.bytecode
C. MyPrg
D. MyPrg.java

Answer : A

Q.8: Binary Java code is also called as ………….

A. Source code
B. Byte code
C. Runtime code
D. Native code

Answer : B

Q.9: What will happen if a Java program by name “Prg.java” is compiled?

A. Compiler error
B. Runtime error
C. No Compiler error
D. Data error

Answer : C

Q.10: …………. Method is the entry point in Java program.

A. MAIN()
B. Main()
C. main()
D. None of the above

Answer : C

Q.11: What is the output ?

class Program {

public static void main(String a){
system.out.println(“HelloWorld”);
}

}

A. Runtime error
B. Compiler error
C. HelloWorld
D. No output

Answer : A

Q.12: Which of the following is the valid entry point in a java program ?

A. public static void main(String …a)
B. public static void Main(String…a)
C. public static void main()
D. public static void Main()

Answer : A

Q.13: What is the output ?

class Program {

public static void main(String[]a){
System.out.println(“HelloWorld”);
}

}

A. Runtime error
B. HelloWorld
C. Compiler error
D. No output

Answer : B

Q.14: What is the output if the command line arguments are : Ram Hari ?

class Program {
public static void main(String args[]) {
system.out.println(” HelloWorld”+args[0]+”,”+args[1]);
}

}

A. HelloWorld
B. HelloWorld Ram, Hari
C. Runtime error
D. None of the above

Answer : B

Q.15: What is the output(when no command line arguments are passed)?

class Program {
public static void main(String args[]) {
system.out.println(” Namaskar :”+args);
}

}

A. Compiler error
B. Runtime error
C. Namaskar :
D. Namaskar :[Ljava.lang.String;@2a139a55

Answer : D

Q.16: What is the output ?

class Program {
public static void main(String ….a) {
system.out.println(” HelloWorld”);
}

}

A. Compiler error
B. Runtime error
C. No output
D. Helloworld

Answer : D

Q.17: Identify the correct signature of “main” method which acts as an entry point.

A. public static void main (String args[])
B. public static void Main (String args[])
C. public static void main ()
D. public static void Main ()

Answer: A

Q.18: What is the output if the command line arguments is : Ram ?

class Program {
public static void main(String args[]) {
system.out.println(” HelloWorld”+args[0]+”,”+args[1]);
}

}

A. HelloWorld Ram
B. HelloWorld
C. Compiler error
D. Runtime error

Answer : D

Q.19: System class belongs to ………….. package.

A. java.lang
B. java.io
C. java.basic
D. java.System

Answer : A

Q.20: What is the output ?

class Program {
public static void main(String args[]) {
system.out.println(” HelloWorld”);
}

}

A. Compiler error
B. Runtime error
C. HelloWorld
D. No error

Answer : B

Q.21: Which of the following is the valid entry point in a java program?

A. public static void Main (String args[])
B. public static void main (String args[])
C. public static void main (String[] args)
D. Both B and C

Answer: D

Q.22: What is the output ?

class Program {
public static void main(String args[]) {
system.out.println(” HelloWorld”);
}

public static void Main(String args[]) {
system.out.println(” HelloWorld”);

}

}

A. No output
B. HelloWorld
C. Compiler error
D. Runtime error

Answer : B

Q.23: What is the output ?

class Program {
public static void main(String args[]) {
system.out.println(” HelloWorld”);
}

public static void main(String args[]) {
system.out.println(” HelloWorld”);

}

}

A. Runtime error
B. Compiler error
C. No output
D. HelloWorld

Answer : B

Q.24: “System.out” is an object of ………. class.

A. Print
B. PrintStream
C. PrintWriter
D. Printer

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);
}

}

A. 30
B. Compiler error
C. Runtime error
D. 10

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));
}

}

A. Runtime error
B. Compiler error
C. 131
D. 132

Answer : A

Tags

Post a Comment

0 Comments
Post a Comment (0)
Our website uses cookies to enhance your experience. Learn More
Accept !