SECTION A — METHODS & OBJECT CREATION
1.
Create a class Calculator with a method add(int a, int b) that returns the sum. Create
an object and call the method.
Hint: Use return type int
Easy
2.
Create a class Greeting with a method sayHello(String name) that prints "Hello, <name>!".
Create an object and call it.
Hint: void method with String parameter
Easy
3.
Create a class Circle with a method area(double radius) that returns the area. Create an
object and print the result.
Hint: Area = π × r²
Easy
4.
Create a class Student with a method displayInfo(String name, int age) that prints the
student's details. Create 3 different objects and call the method.
Hint: Create 3 objects using new keyword
Easy
5.
Create a class EvenOdd with a method check(int number) that returns "Even" or "Odd". Call it
with 5 different numbers.
Hint: Use % operator, return type String
Easy