DIT410  JAVA PROGRAMMING.

UNIVERSITY EXAMINATIONS: 2018/2019
EXAMINATION FOR DIPLOMA IN INFORMATION TECHNOLOGY
DIT 410: JAVA PROGRAMMING
MODE: FULL TIME/PART TIME
ORDINARY EXAMINATIONS
DATE: AUGUST, 2019 TIME: 2 HOURS
INSTRUCTIONS: Answer question ONE and any other TWO.

QUESTION ONE[30 Marks]
a) Differentiate between imperative and object oriented programming paradigms
4 Marks
b) List four reasons that explain why Java programming is popular
4 Marks
c) JVM is an imaginary machine that is implemented by emulating it in software on
a real machine. Code for the JVM is stored in .class file extension, each of which
contains code for at most one public class. Explain four uses of JVM.
8 Marks
d) When an object is created, instance variables are initialized with their respective
default values. What are the default values for the following instance types?
i. Byte
ii. Int
iii. Float
iv. Char
4 Marks
e) With examples differentiate between implicit type casting and explicit type
casting
4 Marks
f) Give the output of the above program
class RelationalOpSample {
public static void main ( String args[] ) {
int num1 = 10, num2 = 30;
System.out.println( num1 + “==” + num2 + ” = ” + ( num1== num2));
System.out.println( num1 + “!=” + num2 + ” = ” + ( num1!= num2));
System.out.println( num1 + “>=” + num2 + ” = ” + ( num1>= num2));
System.out.println( num1 + “<=” + num2 + ” = ” + ( num1<= num2));
}
}
6 Marks
QUESTION TWO [20 Marks]
a) Explain the difference between static and non-static member of a class.
4 Marks
b) Describe with examples the syntax of the following program flow controls and
advice when to use them
i. While
ii. Do while
6 Marks
c) Describe the following flow stubs
iii. Continue
iv. Break
6 Marks
d) Give two rules used for naming variables in Java
4 Mark
QUESTION THREE [20 Marks]
a) What is the relevance of the following keywords as used Java Programming?
Give examples to support your answer.
i. new
ii. extends
iii. implements
9 Marks
b) Create a class named Sweets. Its main() method holds an integer variable named
numberofSweets to which you will assign a value. Create a method to which you
pass numberofSweets. The method displays the sweets in dozens. For example, 40
sweets is 3 dozens and 4 left over.
7 Marks
c) Interfaces are quite useful in programming (Java). Explain TWO uses of
interfaces
4 Marks
QUESTION FOUR [20 Marks]
a) Create a class named Commission that includes three variables: a double sales
figure, a double commission rate, and an integer commission rate. Create two
overloaded methods named compute Commission(). The first method takes two
double arguments representing sales and rate, multiplies them, and then displays
the results. The second method takes two arguments: a double sales figure and an
integer commission rate. This method must divide the commission rate figure by
100.0 before multiplying by the sales figure and displaying the commission.
Supply appropriate values for the variables, and write a main() method that tests
each overloaded method.
12 Marks
b) Briefly outline any four methods used in StringBuffer class.
8 Marks
QUESTION FIVE [20 Marks]
a) Define a wrapper class as used in java langauge.
3 Marks
b) Complete the following table of primitive types using the corresponding wrapper
class for each type.


5 Marks.
c) Explain the concept of method overloading as used in java programming.
4 Marks
d) Write a java program to demonstrate the use of method overloading
8 Marks

(Visited 89 times, 1 visits today)
Share this:

Written by