PROGRAMMING IN JAVA

PROGRAMMING IN JAVA

QUESTION ONE (30 MARKS)

  1. “Java is regarded as popular object oriented language” .Justify this statement(5 Marks)
  2. Expound the garbage  collection technique                                                   (2Marks)
  3. Define the term final with an example                                                           (2Marks)
  4. Write short notes on the following terms.                                                  (8Marks)
  5. Inheritance
  6. Encapsulation
  • Polymorphism
  1. Exception
  2. Distinguish between  method  overriding  and method  overloading  with  example

(4 Marks)

  1. Explain the  following            code snippet                                                               (2 Marks)
  2. Describe an applet (2 Marks)
  3. Briefly describe how to  declare an array   in Java                                       (2 marks)
  4. Highlight eight primitive data types of (4 marks)

QUESTION TWO (20 MARKS)

  1. Discuss on the following terms (4 Marks)
    1. Multithreaded programming
    2. Exception handling
  2. Compare and contrast on the terms abstract class and interfaces (6 marks)
  3. Write a program in Java that accepts the mass (in kilograms) and the height (in meters) of an individual then calculates the body mass index (BMI) based on the formula: BMI=mass/(height*height)                                                   (10 Marks)

 

QUESTION THREE (20 MARKS)

  1. What is an Applet?              (2 Marks)
  2. Explain the life cycle of an Applet.  (8 Marks)
  3. Use an if-else statement to write a program in Java that awards students grades based on the following guidelines; A = 70-100, B = 60 – 69, C = 50-59, D = 40-49, F = 0-39. The program should request the user to input the mark attained by the student, and should return “an invalid input” error in case the user tries to input any value that is not in the range 0-100.                                                                                                                                 (10Marks)

QUESTION FOUR (20 MARKS)

  1. BSCIT student wants to connect his application with database, Describes the steps of how he can established JDBC connection                         (4  Marks)
  2. Write a program in java that accepts two user input numbers: number1 and number2, the program then compares the two numbers and outputs: number1 equals number2 or number1 is less than number2 or number1 is greater than number2 depending on the outcome.                (10 marks)
(Visited 231 times, 1 visits today)
Share this:

Written by