Write a program to print the area of a rectangle by creating a class named 'Area' having two methods. First method named as 'setDim' takes length and breadth of rectangle as parameters and the second method named as 'getArea' returns the area of the rectangle. Length and breadth of rectangle are entered through keyboard. 4. Create a class named 'PrintNumber' to print various numbers of different datatypes by creating different methods with the same name 'printn' having a parameter for each datatype. 5. What is the output of this question? class Test1 { public static void main(String[] args) { int x = 20; System.out.println(x); } static { int x = 10; System.out.print(x + " "); }
Complete all the following questions perfectly as they are linked and connected altogether in Java
3. Write a program to print the area of a rectangle by creating a class named 'Area' having two methods. First method named as 'setDim' takes length
and breadth of rectangle as parameters and the second method named as 'getArea' returns the area of the rectangle. Length and breadth of
rectangle are entered through keyboard.
4. Create a class named 'PrintNumber' to print various numbers of different datatypes by creating different methods with the same name 'printn'
having a parameter for each datatype.
5. What is the output of this question?
class Test1 {
public
static void main(String[] args)
{
int x = 20;
System.out.println(x);
}
static
{
int x = 10;
System.out.print(x + " ");
}
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 6 images