Java Programming
Java Programming
1.With the aid of a diagram briefly describe the stages of the spiral model
[8 marks]
2.Illustrate the difference between JDK and JRE [6 marks]
3 a.Create a java Class which handles complex numbers the class takes as input 2
numbers and performs the following operations
i) Add complex numbers [3 marks]
ii) Subtract two complex numbers [3 marks]
iii)Compare if two complex numbers are equal [3 marks]
vi) The modulus of a complex number 𝑧 = 𝑎 + 𝑏𝑖 is calculated as follows
2 2
𝑎 + 𝑏 write a program which computes the modulus of a given complex
number [3 marks]
b) Explain the following Java keywords. For each write a sentence giving an
overview of what the word is about, then either write a second sentence that shows
how it fits in with related concepts or write a small code-fragment to illustrate its
purpose:
i) switch
ii) class
iii) protected
iv) void
v) interface
[2 marks each]
4. Illustrate the difference between static variables and instance variables [4 marks]
ii) Given the following classes record Point(double x, double y);
Illustrate how you would create an array of 10 Point objects [4 marks]
iii) Briefly explain the operations taking place on the following statement
Point point=new Point(23,32); [3 marks]