0% found this document useful (0 votes)
7 views

Programming 2022

Uploaded by

Jehu Mtine
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
7 views

Programming 2022

Uploaded by

Jehu Mtine
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
School of Natural Sciences Department of Computer Science FINAL EXAMINATION CSC 2000 Computer Programming 15" November 2022 Date: Time: 09:00hrs — 12:00hrs Duration: 3 Hours Venue: NSLT Instructions 1. There are two (2) sections in this exam paper. 2. Only the java programming language should be used in this exam 3. Answer all the questions in Section A and choose any three (3) questions from Section B SECTION A. Short answers (40 marks) You are required to answer all questions in this section. 1. What is Java? [4 marks} 2. List and explain any four features of the Java Programming language. [4 marks] 3. What gives Java its ‘write once and run anywhere’ nature? [4 marks) 4. Briefly discuss the various access modifiers in Java? (4 marks] 5. What is an object? [4 marks] 6. Whats the difference between static (class) method and instance method? [4 marks] 7. What is multiple inheritance and why is it not supported in java? [4 marks] 8. What are the differences between this and super keyword? [4 marks] 8. What is the difference between static binding and dynamic binding? [4 marks] in Java? (4 marks] 10. What is the difference between equals() and SECTION B. Short answers (60 marks) Answer any three (3) of the five (5) questions in this section. Each question carries 20 marks Methods and constructors form a key part of Object Oriented programming a. What is the purpose of static methods and variables? [4 marks] b. What is the purpose of a default constructor? [4 marks] ¢. Why is the main method static? [4 marks] d. What is method overloading and how can it be achieved? [4 marks} What is method overriding and what rules govern it? [4 marks] 1 e. 2. Arrays are useful and powerful data structures. More often than not programmers take this data structure for granted. Write code that demonstrates how arrays are declared and initialized in Java? [4 marks] b. Write a complete Java program that tests if an array contains a specific value. [6 marks] Given two sorted arrays A and B of size p and q, write a complete Java program to merge elements of A with B by maintaining the sorted order i.e. fill A with first p smallest elements and fill B with remaining elements. [10 marks] Example: Input : intl] A= (1,5, 6,7, 8,10) intl] B={2, 4,9) Output: Sorted Arrays: A:[1, 2, 4,5, 6,7] B: [8, 9, 10) 3. Loops are an important and useful construct for programmers a b. What are the types of loops that are defined in the Java programming language? [2 marks] Using any type of loop, write a complete program to print numbers from 1 to 10. [4 marks] Write a complete Program that allows a user to enter two numbers using a key- board. The program then finds the value of the one number raised to the power of other. (Do not use Java built-in Math method) [6 marks] Write a program that generates a random number and asks the user to guess what. the number is. If the user's guess is higher than the random number, the program should display "Too high, try again." If the user's guess is lower than the random number, the program should display "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number. [8 marks] What is aggregation and composition? [4 marks] List all the Java primitive data types? [4 marks] What are the simple rules to giving a valid identifier name? [3 marks] What are the conventions used to name Classes, constants and variables? [3 marks] Briefly explain the types of programming errors a programmer may encounter in java. [6 marks] Illustrate and explain state transitioning of a java thread. [6 marks] In Java programming an object is said to have both state and behavior. What does Java use to define state and behavior? [4 marks] What is a Java prepared statement and how is it implemented? [6 marks] Why is Java an ideal language for database programming? {4 marks] The end of this examination paper

You might also like