0% found this document useful (0 votes)
1 views

Practice Worksheet Basic of Java

This document is a practice worksheet for Grade 9 students on Java programming basics, covering fill-in-the-blanks, multiple choice questions, true/false statements, short answer questions, and code-based exercises. It includes examples of Java syntax and programming concepts such as variable definition, the main method, control structures, and basic input/output operations. The material is intended for educational purposes and is released into the public domain.

Uploaded by

contactkeenan72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Practice Worksheet Basic of Java

This document is a practice worksheet for Grade 9 students on Java programming basics, covering fill-in-the-blanks, multiple choice questions, true/false statements, short answer questions, and code-based exercises. It includes examples of Java syntax and programming concepts such as variable definition, the main method, control structures, and basic input/output operations. The material is intended for educational purposes and is released into the public domain.

Uploaded by

contactkeenan72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Practice Worksheet – Java Programming Basics

Grade: 9 | Board: ICSE | Topic: Java Basics

✦ Section A: Fill in the Blanks


1. class
2. main
3. boolean
4. bytecode
5. string literal

✦ Section B: Multiple Choice Questions


1. b) number1
2. c) Prints "Hello" and moves to next line
3. a) int
4. d) //
5. b) ==

✦ Section C: True or False


1. True
2. False (System.out.println is correct)
3. False (char stores a single character)
4. False (do-while executes at least once)
5. True
✦ Section D: Short Answer Questions
1. Variable Definition:
A variable is a named location in memory used to store data.
Example: int age = 14;
2. Purpose of main():
It's the entry point of any Java application. The Java Virtual
Machine starts execution from the main method.
3. Features of Java:
o Platform Independent
o Object-Oriented
o Secure
(Any other valid features are also acceptable.)
4. Difference between if and switch:
if can check a range or multiple conditions. switch checks a
single value against multiple cases.
Example: Use if for complex logic, switch for menus or options.
5. Syntax of for loop:
java
CopyEdit
for (int i = 1; i <= 5; i++) {
System.out.println(i);
}

✦ Section E: Code-Based Questions


1. Input two numbers and print their sum
java
CopyEdit
import java.util.Scanner;

class Sum {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println("Sum: " + (a + b));
}
}

2. Check even or odd


java
CopyEdit
import java.util.Scanner;

class EvenOdd {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
if (num % 2 == 0)
System.out.println("Even");
else
System.out.println("Odd");
}
}

3. Print numbers 1 to 10 using while


java
CopyEdit
class WhileLoop {
public static void main(String[] args) {
int i = 1;
while (i <= 10) {
System.out.println(i);
i++;
}
}
}

4. Area of a circle
java
CopyEdit
import java.util.Scanner;

class CircleArea {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double r = sc.nextDouble();
double area = 3.14 * r * r;
System.out.println("Area = " + area);
}
}

✦ Bonus Challenge: Pass/Fail Program


java
CopyEdit
import java.util.Scanner;

class Result {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int marks = sc.nextInt();
if (marks >= 40)
System.out.println("Pass");
else
System.out.println("Fail");
}
}
No Copyright Claimed
This material has been created for educational purposes and is intended for
free public use.
The content in this document is released into the public domain by the author
and contributors.
You are free to copy, share, modify, distribute, or use this material in any form,
with or without attribution.
This resource was created with the support of AI tools and compiled by Annexa
Academics for the benefit of students and educators.

****************************************************************

You might also like