How java compiles and interpret: Compiler reads java source code and then it generates object code which will then be interpreted (byte code) to product a result that will be printed on the screen. - Illustrate! 2. Different ways of program checking: - Dry-run: One person will pretend to be the computer or compiler and checks the whole program line by line. - Walk-Through: Exposing the program to a group of colleagues for a group criticism. - Catalytic Checking: the designer tries to describe in detail to a single colleague how the program works. - Independent Inspection: pass the program to a colleague and then go through the whole program alone. 3. Describe the following: - Variables: are the named storage locations of values and should be declared with a type of data it will hold. - Comments: make the program readable and easy to understand. - Operators: are special symbols which are used to represent mathematical, logical and relational operations. + Arithmetic: +,-,*,/; + Logical: AND,NOT,OR + Relational: >,<,!= 4. Simple class and methods: public class test { public static void Display() { System.out.print("hello genetic computer school!"); } public static void main(String[] args) { Display(); } } 5. Class, constructor and destructor: public class Time { int hour, minute; public Time() //constructor { this.hour = 0; this.minute = 0; } ~Time() //destructor { hour = 0; minute = 0; } public static void main (String[] args) { Time t1 = new Time(); t1.hour = 11; t1.minute = 30; System.out.println(t1); } }
6. Switch in java and example: - The purpose of switch is to provide fixed options to a particular program structure. Its another way of fixed conditional statement. import java.ulti.Scanner public class Test { public static void main (String [] args) { int a = 0; System.out.println(1 : Hello!); System.out.println(2 : How are u?); System.out.println(3 : Fine, thanks!); System.out.print(Choose a = ); Scanner sc = new Scanner(); a = sc.nextInt(); switch(a) { Case 1: System.out.println(Hello!); Break; Case 2: System.out.println(How are u?); Break; Default: System.out.println(Fine, thanks!); Break; } } } 7. Array with example: array is the named collection of values where all values are the same type and each value is identified by an index. String [] data; int [] a = new int [10]; 8. Examples on initializing: - One-dimensional Array: int [] a = new int [10]; a[0] = 5; a[1] = 14; a[2] = 24; - Two-dimensional Array int [][] a = new int [3][2]; a[0][0] = 13; a[0][1] = 24; a[2][2] =0; 9. Fundamental searching technique:
10. Object oriented programming: - Is the type of programming in which it focuses objects and classes. - OOP models are organized around objects and classes which a lot different from procedural structure where it depends on action and logic.