Anda di halaman 1dari 2

1.

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.

- Objects: are the basic unit of object


orientation with behaviors and identity. Objects are instance of classes. - Classes: are the center point of OOP which contain data and code with behaviors. Classes are made up of objects. - Overloading: is the type of structure in which the methods have the same name signature but different number or data types of parameters.

- Inheritance: is the process by which one


object acquires the properties of another object. it stands for its concept of hierarchical classification. - Encapsulation: is the mechanism that bins data and code it manipulates and keeps both safe from outside interference and misuse. Its a protective wall that preventing code and data from being randomly accessed by other code defined outside the wall.

- Abstraction: is used to hide certain details


and only show the essential feature of the object. In other words, it deals with the outside view of an object (interface). - Polymorphism : from the Greek, meaning many forms. it allows one interface to be used for a general class of actions. In other words, one common interface can be used for a group of related methods.

- Overloading : is the powerful feature; it


should be used only if it is needed. Use it when the program needs multiple methods with different parameters, but the methods do the same thing. - Overriding : is a method which means that its entire functionality is being replaced. Overriding is something done in a child class to a method defined in a parent class. 11. Explain the given functions in Java - Random(): Is used to generate randomized numbers - Length (): Is used to get the length or size of any given string - charAt(): Is used to identify the individual character of any string data - indexOf(): Is used to get number index or element of a given array data 12. Linked list : is a type of data structure, where the structure is made up of sequence of nodes and each node points to another node (previous or next node)

- Binary search: searching an item which is


already sorted and it will divide array of data into two and start searching from the beginning and the middle. i. Compare the value of variable you are trying to look for in the middle value of list. ii. If its equal then the process is done. iii. If the value of variable is less than then it searches the first half of list. iv. --------greater than then ---- second -----. - Linear Search: searching item linearly and start searching from the beginning until finding the data you want to look for.

Anda mungkin juga menyukai