Chapter 4 : HelloWorld program – II
Q.1: How many classes can a Java program can have ?
A. 1
B. 2
C. 4
D. None of the above
Answer : D
Q.2: The “.class” file has the same name as the class defined in the program.
A. True
B. False
C. Sometimes
D. None of the above
Answer : A
Q.3: How many entry point “main” methods can a class have ?
A. 1
B. 2
C. 4
D. 8
Answer : A
Q.4: If a Java program has 4 classes then how many class files will be generated after compilation ?
A. 2
B. 1
C. 4
D. 8
Answer :
Q.5: Main method can be overloaded.
A. True
B. False
Answer : A
Q.6: What is the output?
class Program {
public static void main(String args[]) {
System.out.println(” Namaskar”);
}
public static void main() {
System.out.println(” Main() method”);
}
public void main(String ar) {
System.out.println(” String argument-main”);
}
}
A. Namaskar
B. Main() method
C. String agrument-main
D. Runtime error
Answer : A
Q.7 : What is the output ?
class Program {
public static void main(String args[]) {
System.out.println(” Namaskar”);
}
public static void main(String….args) {
System.out.println(“Vanakkam”);
}
}
A. Vanakkam
B. Namaskar
C. Runtime error
D. Compiler error
Answer : D
Q.8: What is the output ( when Test class is executed)?
class Program {
public static void main(String args[]) {
System.out.println(” Program class – Main method”);
}
}
class Test {
public static void main(Strin[]args) {
System.out.println(“Test class – Main method”);
}
}
A. Compiler error
B. Runtime error
C. Program class – Main method
D. Test class – Main method
Answer : D
Q.9: Identify the invalid signature for main method which is an entry point in a class.
A. public static void main (String args[])
B. public static void main (String[]args)
C. public static void main (String… args)
D. public static void main (String….args[])
Answer : D
Q.10: How many public classes can be created in a java program ?
A. 1
B. 2
C. Any number
D. 0
Answer : A
Q.11: What is the output ?
class Program {
public static void main(String args[]) {
System.out.println(” Program Namaskar”);
}
public static void main(String….args) {
System.out.println(“Program Vanakkam”);
}
}
class Test {
public static void main(String args[]) {
System.out.println(” Test Namaskar”);
}
public static void main(String….args) {
System.out.println(“Test Vanakkam”);
}
}
A. Runtime error
B. Compiler error
C. Program Namaskar
D. Test Namaskar
Answer : B
Q.12: What is the output ( when Test class is executed)?
class Program {
public static void main(String args[]) {
System.out.println(” Program class – Main method”);
}
}
class Test {
public static void main(String[]args) {
System.out.println(“Test class – Main method”);
}
}
A. Compiler error
B. Program class – Main method
C. Runtime error
D. Test class – Main method
Answer : C
Q.13: The program name and public class should be same.
A. True
B. False
Answer : A
Q.14: How many default scoped classes (package level) can be created in a program ?
A. 1
B. 2
C. 0
D. Any number
Answer : D
Q.15: What is the output( The name of the java program is MyPrg.jave)?
// MyPrg.java
public class Prg{
public static void main ( String args[]){
System.out.println(“Namaste Java”);
}
}
A. Namaste Java
B. Runtime error
C. Compiler error
D. None of the above
Answer : C
Q.16: How many private classes can be created in a java program?
A.0
B. 1
C. 2
D. Any number
Answer : A
Q.17: What is the output ?
public private class Prg{
public static void main(String args[]){
System.out.println(“Namaste Java”);
}
}
A. Runtime error
B. Namaste Java
C. Compiler error
D. None of the above
Answer : C
Q.18: How many protected classes can be created in a java program?
A. 1
B. 2
C. 0
D. Any number
Answer : C
Q.19: JIT stand s for …………..
A. Just In Time Compilation
B. Java In Time Compilation
C. Java Information Technology
D. Java Input Technique
Answer : A
Q.20: JIT is performed by …………
A. Compiler
B. Interpreter
C. Bytecode reader
D. Security Manager
Answer : B
Q.21: ………… activity happens at runtime.
A. Compilation
B.JIT
C. Coding
D. None of the above
Answer : B
Q.22: The process of conversion of Bytecode to Native code is called as ………..
A. Compilation
B. Garbage collection
C. JIT
D. Testing
Answer : C
Q.23: Binary code of Java is called as ………
A. Source code
B. IL code
C. Byte code
D. Native code
Answer : C
Q.24: The process of converting source code to byte code is called as ………..
A. Compilation
B. Interpretation
C. JIT
D. None of the above
Answer : A
Q.25: FileOutputStream class belongs to ……….
A. java.lang
B. java.io
C. java.net
D. None of the above
Answer : B
Q.26: Java byte code targets ………. operating syste.
A. Windows
B. Linux
C. Mac OS
d. None of the above
Answer : D
Q.27: Java bytecode is saved as ……….. file.
A. .java
B. .class
C. .exe
D. .byc
Answer : B
Q.28: ………….. Identifies the output stream.
A. FileDescriptor.out
B. FileDescriptor.stdout
C. FileDescriptor.vdu
D. FileDescriptor.std
Answer : A
Q.29: Identify the correct statement.
A. Bytecode targets Windows OS
B. Bytecode targets Linux OS
C. Bytecode targets JVM
D. Bytecode targets Ubuntu
Answer : C
Q.30: Identify the correct statement.
A. Conversion of Native code to Bytecode is called as JIT
B. Conversion of Bytecode to Source code is called compilation
C. Conversion of Bytecode to Native code is called Garbage collection
D. Conversion of Source code to Bytecode is called as Compilation
Answer : D
Q.31: PrintStream class belongs to …………. package.
A. java.io
B. java. lang
C. java.net
D. java.data
Answer : A
Q.32: Bytecode targets …………
A. Java compiler
B. JVM
C. Windows OS
d. Linux OS
Answer : B