🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Which company originally developed Java? a. Microsoft b. IBM c. Sun Microsystems d. Google Answer: c What is the primary feature of Java that allows it to run on different platforms? a. Garbage Collection b. Multi-threading c. Object-oriented nature d. Write Once, Run Anywhere (WORA) Answer:...

Which company originally developed Java? a. Microsoft b. IBM c. Sun Microsystems d. Google Answer: c What is the primary feature of Java that allows it to run on different platforms? a. Garbage Collection b. Multi-threading c. Object-oriented nature d. Write Once, Run Anywhere (WORA) Answer: d Which software must be installed to run Java programs? a. Java Virtual Machine (JVM) b. Java Development Kit (JDK) c. Java Runtime Environment (JRE) d. Integrated Development Environment (IDE) Answer: c What is the Java compiler responsible for? a. Executing Java programs b. Converting source code into bytecode c. Interpreting bytecode into machine code d. Managing Java libraries Answer: b Which of the following is a feature of the Java Runtime Environment (JRE)? a. Provides class libraries b. Converts bytecode to machine code c. Compiles Java source files d. Manages network protocols Answer: a What is bytecode in Java? a. The machine code produced by the JVM b. An intermediate code that is platform-independent c. The source code written by the programmer d. A command line code for Java execution Answer: b Which of the following is a reserved word in Java? a. method b. static c. Number d. System Answer: b Which keyword in Java is used to prevent a method from returning a value? a. return b. private c. static d. void Answer: d What is a class in Java? a. A method used to initialize variables b. A collection of objects and methods c. A type of loop structure d. A package that contains libraries Answer: b Which data type would you use to store true/false values in Java? a. int b. boolean c. float d. char Answer: b In the program public static void main(String[] args), what does String[] args represent? a. A method return type b. An array of command-line arguments c. The name of the class d. A Java keyword Answer: b Which method is always required in a Java application? a. start() b. print() c. main() d. execute() Answer: c Java uses both a compiler and an interpreter to run programs. The compiler translates Java code into _____. a. machine code b. binary code c. bytecode d. assembly code Answer: c Which of the following is NOT a benefit of Java? a. Active community support b. Inbuilt garbage collection c. Platform independence d. Hardware-specific dependencies Answer: d What is the output of the following code: a. Prints: Hello, Java b. Prints: "Hello, Java" c. Error: missing quotes d. Nothing, it only compiles Answer: a What type of comment is in Java? a. Single-line comment b. Multi-line comment c. Javadoc comment d. String literal Answer: b Which of the following is used to handle errors in Java? a. int b. try-catch block c. static method d. boolean Answer: b What does the System.out.println method do in Java? a. Saves the program b. Compiles the code c. Prints output to the console d. Initializes variables Answer: c Which of the following is NOT a valid identifier in Java? a. $myValue b. _count c. 5thValue d. myVar Answer: c Which command is used to compile a Java program? a. javac b. java c. jre d. jvm Answer: a True/False Questions (21-25) Java is considered a platform-independent language. Answer: True In Java, the keyword public makes a method or class accessible to all other classes. Answer: True The Java interpreter converts source code directly into machine code. Answer: False (It converts bytecode to machine code) The Java keyword main is used to define variables. Answer: False (It defines the main method) Java does not allow the use of underscores (_) in variable names. Answer: False (Underscores are allowed in variable names) Fill-in-the-Blank Questions (26-30) The process of converting Java source code into bytecode is done by the __________. Answer: Java compiler In a Java program, the main method must always be declared as __________. Answer: static A method that does not return a value is declared with the keyword __________. Answer: void The Java Development Kit (JDK) includes the __________ and tools for developing Java applications. Answer: Java Runtime Environment (JRE) The Java command javac is used to __________ Java programs. Answer: compile

Use Quizgecko on...
Browser
Browser