August
1999 QUESTION 1 (Compulsory) Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
(a) | (i) Explain what is meant by the term Java
Virtual Machine. (ii) Explain why the concept of the virtual machine aids the portability of code.
|
[3] [2] |
(b) | Java is an Object Oriented
programming language. Explain what is meant by the following terms in the context of
object oriented programming: (i) Encapsulation (ii) Inheritance (iii) Overloading
|
[1] [1] [1] |
(c) | Identify the difference between a class
and an object.
|
[2] |
(d) | (i) Define a public java class MyAddress, which contains 2
member variables, HouseNumber, which is an integer, and StreetName, which is a string. (ii) Write a constructor function for your class, which will take in two parameters that will initialize the member variables of your class. (iii) Write a function ShowMeHome, which is a public member of your class MyAddress, with a void return type, which will print out the values of HouseNumber and StreetName. (iv)Write a small fragment of Java code which will construct an object of type MyAddress, and cause it to print out its members.
|
[3] [2] [3]
|