Page 251 - CA_Blue( J )_Class10
P. 251

return 0.5 * base * height;
                            }
                            public static void main(String[] args) {
                                Areacal cal = new Areacal();
                                double circleArea = cal.areaOfCircle(5);
                                double rectangleArea = cal.areaOfRectangle(4, 6);
                                double triangleArea = cal.areaOfTriangle(3, 4);
                                System.out.println("Area of Circle: " + circleArea);
                                System.out.println("Area of Rectangle: " + rectangleArea);
                                System.out.println("Area of Triangle: " + triangleArea);
                            }
                        }
                       1.   What will be the output when Jenny runs her program?
                           a. Area of Circle: 78.5398, Area of Rectangle: 24, Area of Triangle: 6
                           b. Area of Circle: 25, Area of Rectangle: 24, Area of Triangle: 6
                           c. Area of Circle: 78.5398, Area of Rectangle: 10, Area of Triangle: 6
                           d. Area of Circle: 78.5398, Area of Rectangle: 24, Area of Triangle: 12
                       2.   What value does the method double areaOfRectangle(double length, double breadth) returns
                           a. 4                                        b. 6
                           c. 24                                       d. 12
                       3.   What is the name of the object of the class Areacal.
                           a. Areacal                                  b. cal
                           c. rectangleArea                            d. Areacal cal
                       4.     Name the variable that is used to receive the return value of the method areaOfTriangle and what type of value is
                           returned.
                           a. circleArea , int                         b. triangleArea , int
                           c. triangleArea , double                    d. triangleArea , 6.0
                       5.   What is the use of String[] args in main() method?
                           a. An array of String objects that stores the command-line arguments.
                           b. A String value that stores the command-line arguments.
                           c. It is a syntax error in the program
                           d. None of these

                      Unsolved Programs


                    1.  Write a method automorphic(int) to input a number and print whether the number is an Automorphic number or not. An
                                                                                                            2
                        automorphic number is a number whose square "ends" in the same digits as the number itself. For example, 5  = 25.
                    2.  Write a program with class name "calculator" having three methods sum (int, int), subtract(int, int) and product(int, int) which
                        will calculate the sum, difference or product of two numbers using the concept of switch case.
                    3.  Write a program to input a sentence and print all the vowel using method vowel(String) and all the consonants using the method
                        consonant(String).
                    4.  Write a program to input a sentence and print the reverse string using the method rev_string(String).
                    5.  Write a program to input a number and print all the prime numbers up to n using the method prime(int). A prime number is a
                        number that is divisible by 1 and itself.
                    6.  Write a program to input the length and breadth of a rectangle from the main() method. Using the methods int area(int , int) and int
                        perimeter(int , int) calculates the area and perimeter of the rectangle respectively and returns the values to the main() method.



                                                                                                                       249
                                                                                                 User-defined Methods   249
   246   247   248   249   250   251   252   253   254   255   256