Java Unit 1 - Scenario Based 1-Mark Questions
Q1. Overview of Java
Ravi is curious to know why Java was developed. What was the main objective behind creating Java?
Answer: To develop a platform-independent programming language that runs on any device using the
concept 'Write Once, Run Anywhere'.
Q2. Java Buzzwords
Sneha read that Java is robust'. What does this mean?
Answer: Java is robust because it handles errors effectively and has strong memory management.
Q3. OOP Principles
A student wants to hide class data and allow access only through methods. Which OOP principle is this?
Answer: Encapsulation.
Q4. Simple Java Program
What is the output of this code?
System.out.println("Hello Java!");
Answer: Hello Java!
Q5. Data Types
Which data type is suitable to store a student's percentage marks?
Answer: float or double.
Q6. Variables Scope
Where is a variable declared inside a method accessible?
Answer: Only within that method.
Q7. Operators
What will be the output of 5 + 3 * 2 in Java?
Answer: 11.
Q8. Arrays
Which data structure is best to store marks of 5 students?
Answer: Array.
Q9. Control Statements
Which statement is used to execute a block only if a condition is true?
Answer: if statement.