Introduction to Programming in Java with BlueJ: 20 MCQs

All 20 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 10 questions

Q1. Which company developed Java and in which year?

Beginner
A Microsoft in 1995
B IBM in 1995
C Apple in 1995
D Sun Microsystems in 1995

Answers and explanations are in the Veda app.

Q2. What does WORA stand for?

Beginner
A Write Often, Run Anywhere
B Run Once, Write Anywhere
C Write Once, Read Anywhere
D Write Once, Run Anywhere

Answers and explanations are in the Veda app.

Q3. Which component makes Java platform-independent?

Beginner
A The JVM
B The compiler
C BlueJ
D The JDK

Answers and explanations are in the Veda app.

Q4. What is the primary purpose of BlueJ?

Beginner
A To provide an educational IDE for Java
B To serve as a Java compiler
C To design Java logos
D To replace the JVM

Answers and explanations are in the Veda app.

Q5. Which of the following is NOT one of the five steps of programming?

Beginner
A Compiling
B Debugging
C Identifying the problem
D Designing

Answers and explanations are in the Veda app.

Q6. Who coined the term 'bug' in computing?

Beginner
A Grace Hopper
B Joe Palrang
C James Gosling
D Duke

Answers and explanations are in the Veda app.

Q7. What is the size of an int in Java?

Beginner
A 1 byte
B 8 bytes
C 2 bytes
D 4 bytes

Answers and explanations are in the Veda app.

Q8. Where is a local variable declared?

Beginner
A Inside a class but outside methods
B Inside a method
C With the static keyword
D In the main method only

Answers and explanations are in the Veda app.

Q9. Which operator is used for logical AND?

Beginner
A &
B ||
C &&
D !

Answers and explanations are in the Veda app.

Q10. Java is platform-independent because it compiles to byte code, which can run on any operating system with a Java interpreter (JVM).

Beginner
A True
B False

Answers and explanations are in the Veda app.

Building up · 5 questions

Q11. Which of the following is a valid Java identifier?

Intermediate
A my-var
B 2ndValue
C _value
D class

Answers and explanations are in the Veda app.

Q12. Which of these is a derived data type?

Intermediate
A boolean
B char
C array
D int

Answers and explanations are in the Veda app.

Q13. In an if-else-if ladder, which condition's block executes?

Intermediate
A All true conditions
B The last true condition
C The first true condition
D The else block always

Answers and explanations are in the Veda app.

Q14. What is the correct order of steps to run a program in BlueJ?

Intermediate
A Create project, create class, write code, compile, execute
B Compile, create project, write code, execute, create class
C Write code, create project, compile, create class, execute
D Create class, create project, write code, compile, execute

Answers and explanations are in the Veda app.

Q15. In the context of Java programming, what is the primary advantage of using byte code over machine code?

Intermediate
A Byte code requires no compilation before execution.
B Byte code is platform-independent and can run on any system with a JVM.
C Byte code is faster to execute than machine code.
D Byte code is easier to read and understand than machine code.

Answers and explanations are in the Veda app.

Topper level · 5 questions

Q16. Which of the following is a syntax error?

Advanced
A Infinite loop
B Missing a semicolon at the end of a statement
C Dividing by zero
D Using a variable before assigning it

Answers and explanations are in the Veda app.

Q17. Given the following Java program snippet, identify the output when executed in BlueJ: ```java public class Test { public static void main(String[] args) { int a = 5; int b = 10; if (a < b) { System.out.println("a is less than b"); } else if (a == b) { System.out.println("a is equal to b"); } else { System.out.println("a is greater than b"); } } } ```

Advanced
A a is equal to b
B a is greater than b
C No output due to a syntax error
D a is less than b

Answers and explanations are in the Veda app.

Q18. Consider the following code snippet in BlueJ: ```java public class Example { static int count = 0; public Example() { count++; } public static void main(String[] args) { Example obj1 = new Example(); Example obj2 = new Example(); System.out.println(count); } } ``` What will be printed when this program is executed?

Advanced
A 0
B 2
C 1
D Compilation error

Answers and explanations are in the Veda app.

Q19. Analyze the following Java method and determine what happens if `x` is passed as 10: ```java public void checkValue(int x) { if (x > 5) { System.out.println("Greater than 5"); } else if (x < 5) { System.out.println("Less than 5"); } else { System.out.println("Equal to 5"); } } ```

Advanced
A Greater than 5
B Equal to 5
C Less than 5
D No output

Answers and explanations are in the Veda app.

Q20. Given the following code snippet, what will be the output when executed in BlueJ? ```java public class Main { public static void main(String[] args) { for (int i = 0; i < 5; i++) { if (i == 3) { break; } System.out.print(i + " "); } } } ```

Advanced
A 3 4
B 0 1 2 3
C 0 1 2
D 0 1 2 3 4

Answers and explanations are in the Veda app.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free to start, in more than 40 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Paper Solver

Get Veda free See what students get

Free to start · Android app and web · More than 40 languages