This week we have a list of 5 Multiple Choice Questions (MCQ), which you can use to test your knowledge on JAVA.
These are helpful practice questions which will help the students of ICSE (Class 9-10) and ISC (Class 11-12) in their preparation for their Computer Application and Computer Science Exams respectively. [To know more about these weekly practice questions, Click Here]
You need to select any one of the four given options, and reply it as comments by filling the “Leave a Reply” section below this post.
The correct answers will be posted before next Sunday.
1. The Java compiler translates Java programs to intermediate level language called:
(a) Machine Language
(b) Byte Code
(c) System Language
(d) Native Executable Code
2. double c , x = 5, y=10;
c = x * y + z/2.5;
What is the value now stored in c?
3. Java Virtual Machine (JVM) is a:
(c) Machine Code
(d) Byte Code
4. If a function returns a value, the return type of the function will not be:
(d) None of the above
5. Which of the following can be used when you know the number of times we have to perform any given task:
(a) for loop
(b) while loop
(c) do-while loop
(d) All of the above
The Correct answers are marked in blue color.
1. A program written in Java (the source code) is first passed through a Java Compiler. The Java compiler then translates the Java program to intermediate level language called Byte Codes which are then interpreted by a special Java Interpreter called Java Virtual Machine (JVM). The JVM then translates each instruction of byte code into instructions that the computer in use can execute i.e. Machine Code.
Remember this is how Java Compilation works:
Java Program (Source Code) → Java Compiler → Intermediate Code (Byte Code) → Byte Code Interpreter (JVM) → Machine Code
2. The execution is as follows:
c = x * y + z/2.5;
c = 5 * 10 + 51/2.5;
c = 50 + 20.4;
c = 70.4;
3. Read explanation to question 1.
4. If a function does not return any value, then it must have ‘void’ return before it’s name. And if it returns a value, then the data-type of the value being returned is written before it’s name.
Hence, if a function returns a value, the return type of the function cannot be void.
5. For loop, While loop and do-while loop can all be used when know the number of times we have to perform any given task.