Yusif Suleiman
Java Assignment
Section A
A1. a). byte b). float c). String d). char e). boolean A2. a). public void start() b). init() c). start() d). destroy() A3. a). False b). True c). False d). False e). True A4. i). ii). iii). iv). v). vi). vii).
2308-0703-0223
400 289 196 121 64 25 4
A5. a). b). (iv) object-oriented language c). d). (iv) flowchart e). (iv) calculate_age A6. import [Link].*; public class A6 { Introduction to Java 1 Informatics Academy
Yusif Suleiman
2308-0703-0223
public static void main(String [] args) throws Exception { String no1, no2; int a, b; BuffredReder input = new BufferedReader(new InputStreamReder([Link])); A7. a). invalid because it begin with number and space b). valid c). invalid because it is java reserved key word d). valid
Section B
B1. (a). i). Terminal (start/stop)
ii). Process(rectangle)
iii). Input/output(Paralogram)
iv). Decision(Diamond)
Introduction to Java
Informatics Academy
Yusif Suleiman
v). Connector (Circle)
2308-0703-0223
(b). { if(stream= = S) [Link](Special stream); else if(Stream= =E) [Link](Express stream); else if(Stream= =N) [Link](Normal stream); else [Link](No such stream); }
(c). Switch(Stream) { Case S: [Link](Special stream); Break; Case E: [Link](Express stream); Break; Case N: [Link](Normal stream); Break; default: [Link](No such stream); }
Introduction to Java
Informatics Academy
Yusif Suleiman
(d).
2308-0703-0223
B2 (a) (b) i). Inheritance: is ability of an object to acquire the attribute or behavior of other objects or classes, this allows object to have one or more lower classes under it. ii). Encapsulation: is ability to bind data and procedures together into a single object and keep them safe from interference or misuse. iii). Polymorphism: is ability to take many forms by an objects, it also consent one interface to be used for a general class of action. (c) i. (d). array is a collection of data items that are of the same data type, array can be created of any data type, array may have one or two more dimensions (e).
Introduction to Java
Informatics Academy