This preview shows page 1 - 3 out of 5 pages.

KENYA METHODIST UNIVERSITY END OF 3 RD TRIMESTER 2018 (PT) EXAMINATION SCHOOL : SCIENCE AND TECHNOLOGY DEPARTMENT : COMPUTER SCIENCE UNIT CODE : BBIT-223/CISY 210 UNIT TITLE : OBJECT ORIENTED PROGRAMMING TIME : 2 HOURS INSTRUCTIONS Answer all Questions in Section A and any Two in Section B. SECTION A Question 1 (One)-30 Marks a) Define the following terms: (2 marks) a. Encapsulation b. Method overriding b) Consider the following program, saved as Exams.java, to answer the questions that follow: a. The program has 4 errors. Identify these errors and correct them (4 marks) b. What error will be generated if we omitted line 3? (1 mark) c. What will this program output if you use your own data? Your answer must include all the required output. (3 marks) 1 // Exam Program with Errors 2 3 import java.util.Scanner; 4 5 public class Exams2 6 { 7 public static void main(String[] arg) 8 { Page 1 of 5/ BBIT-223/CISY 210
Image of page 1

Subscribe to view the full document.

9 Scanner s = new Scanner(system.in()); 10 11 System.out.print( "What is your full name?" ); 12 13 String name = s.nextLine(); 14 15 System.out.println( "How old are you?" ); 16 17 int age = s.nextInt; 18 19 int older = age + 10; 20 21 System.out.println( "In 10 years you will be " + older); 22 23 } 24 25 } c) Consider the following table of numbers and answer the questions that follow: 4 4 3 2 4 1 5 2 5 1 1 0 a. Write one java statement that can be used to create and initialize a 2D array that creates the above table. Assume the name of the array is numbers.
Image of page 2
Image of page 3
  • Winter '15
  • Joyce Wambugu

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes