

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Instructions:AnswerQuestion1andAnyOtherTwo. INSTRUCTIONS: Attempt Question ONE and any other TWO questions. QUESTION ONE [30 MARKS] a. Explain any 3 rules for naming identifiers in java programming. ( Marks) b. Define a static method and give its advantage. ( Marks) c. Write a Java Program to display odd numbers between 1 to 10 using a for loop. ( Marks) d. Classes are user defined types that model real world entities from which objects are created. Using appropriate examples: i. Explain the members of a class (3 Marks) ii. Show the syntax of defining a class in java (2 Marks) e. Write a program that reads the dimensions of a triangle from a user using either Scanner class or the JOptionPane, computes the area and perimeter of the triangle and displays the results. ( Marks) f. Write a simple java program to check a person’s voting eligibility using a condition ( Marks) g. Differentiate between method overriding and method overloading? Explain with example. ( Marks) QUESTION TWO [15 MARKS] a. Define the following terms (2 Marks) i. Class
ii. Object b. Differentiate between public and private access modifier (4 Marks) c. Write a program that defines an array of 5 integers then obtains the average of those values (4 Marks) d. Write a simple java program that uses a while loop to display all the odd numbers from 0 to 30 in reverse order (4 Marks) e. Explain whether java main () method can be overloaded. (1 Mark) QUESTION THREE [15 MARKS] a. Outline three properties of a constructor method (3 Marks ) b. Write a java program that defines a function which accepts two integers and returns their product (3 Marks) c. What are comments used for in Java programming? Give two types of comments (3 Marks) d. What is the use of Super keyword in Java? (2Marks) e. Give the syntax of declaration of the following in java programming. (4 Marks) i. Method ii. Array QUESTION FOUR [15 MARKS] a. Write a java program that uses a switch structure to determine the grade of a student ( 5Marks) b. Write a simple java program to demonstrate inheritance, using person and student class (5 Marks) c. Write a Java program that accepts two integer values from the user and return the largest. However, if the two values are the same, return 0. (5 Marks)