Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

IT PF Reviewer Merged

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

IT-PF01 REVIEWER

PS: This reviewer are based on


notes I have and sir prince ppt,
Goodluck to our quiz and enjoy
studying.

Lesson 1:

- Procedural Oriented Programming (POP) and Object Oriented


Programming (OOP) are the high level languages world and are
widely used in development of applications
- Object Oriented Programming – is a programming language that uses
classes and objects to create models based on the real world
environment.
- Procedural Oriented Programming – is a language that follows a step
by step approach breakdown a task into a collection of variables and
routines (or subroutines) through a sequence of instructions.

Approach
- In OOPs concept of objects and classes is introduced and hence
and the program is divided into small chunks called objects
which are instances of classes.
- On the other hand in case of POP the main program is divided
into small part based on the functions and is treated as separate
program for individual smaller program.

Security
- Due to abstraction in OOPs data hiding is possible and hence it
is more secure than POP.
- On other hand POP is less secure as compare to OOPs

Complexity
- Oops due to modularity in its programs is less complex and
hence new data objects can be created easily from existing
objects making object oriented programs easy to modify.
- On other hand there’s no simple process to add data in POP at
least not without revising the whole program.

Java
- Java – was first introduced By Sun Microsystems and was further
acquired by Oracle in 1995.
- It’s first name was Oak.
- It was Immediately collaborated with Netscape Navigator’s Java
Virtual Machine (JVM).
- Java adapted the syntax of C++.
- It Promised Write Once, Run Anywhere (WORA), providing no cost
run times on popular platforms.

Class – A class can be defined as a template/blueprint that describes the


behaviors/states that object of its type support.
Object – An object represents an entity in the real world that can be distinctly
identified. Objects have states and behaviors.
Methods – A method is basically a behavior.
Attribute – A characteristic/s that describes an object.
Instance Variables – Each object has its unique set of instances variables.

Example of Class,
Object, Attributes,
and Methods:
Lesson 2
Java Programming Life Cycle

Java undergoes programming stages such as:


- Writing code
- Compiling code
- Executing application

Essential Tools in Java Programming

For PC users;
- Linux/Windows/Mac Operating System
- Java JDK 6 or higher versions
- Any text editor

For SMARTPHONES users;


- Android/IOS
- Jvdroid/JavaNIDE

JDK – Java Development Kit

Lesson 3

Case Sensitivity
Java is case sensitive, which means identifier HelloWorld and
helloWorld would have different meaning.
Naming Convention

Class names – For all class names, firs letter should be in Upper Case, If
several words are used to form a name of the class, each inner words are
used to form a name of the class, each inner word’s first letter should be in
Upper Case. Example class MyFirstJavaClass.
Method Names - All method names should start with a Lower Case
Letter.
Constant Names – All constant names should be in written in Upper
Case. If several words are used to form the name of the constant, then put
underscore between words.
Variable Name - should be start in lower Case and then Capitalize the
first letter of every subsequent word.
Program File Name
Name of the program file should exactly match the class name. When
saving the file, you should save it using the class name (Remember Java is
case sensitive) and add ‘.java’ to the end of the name.

Main Method
public static void main(String args []) { - Java Program processing starts
from the main() method, which is a mandatory part of every Java
application.

Java Identifiers
 All identifiers should begin with a letter (A to Z or a to z), currency
character ($) or an underscore (_).

 After the first character, identifiers can have any combination of


characters.

 A keyword cannot be used as an identifier.

 Most importantly, identifiers are case sensitive.

 Examples of legal identifiers: age, $salary, _value, __1_value.


 Examples of illegal identifiers: 123abc, -salary.

 A class name should start from a capital case letter and long names
should use camel casing. For example: TaxationDepartment

 Object name should start from lower case letter and long names
should use camel casing. For example: taxationDepartment

Java Modifiers

Like other language, it is possible to modify classes, methods, etc., by


using modifiers. There are two categories of modifiers:
Access Modifiers: default, public, protected, private
Non-access Modifier: final, abstract

Java Variables

Types of variables in Java:

1. Local variables
2. Class Variables (Static Variables)
3. Instance Variables (Non-static variables)

Java Arrays

Arrays – are object that store multiple variables of the same type.
However, an array itself is an object. We will look into how to declare,
construct and initialize in the upcoming chapters.

Java Reserved Words

The following list shows the reserved words in Java. These reserved words
may not be used as constant or variable or any other identifier names.
Escape Sequence in Java

A character preceded by a backslash (\) is an escape sequence and has a


special meaning to the compiler.

Java Program Comments

Comments can be used to explain Java code, and to make it more


readable. It can also be used to prevent execution when testing alternative
code.

Single-line Comments - Single line comments start with two forward


slashes (//) . Any text between // and the end of the line is ignored by Java
( will not be executed)

// This is a comment.

System.out.println(“Hello World”);

Java Multipl-line Comments


Multi line comments start with /* and ends with */. Any text between /*
and*/ will be ignored by java.
/* The code below will print the words Hello World to the screen, and it is
amazing */

System.out.println(“Hello World”);

Part of the Java Program

Class Header

Main Method

Blocks

Made by your Secretary 


ITPF01 REVIEWER

Constant and Variables


- Are memory location that can store a value.

Constant

- Are data whose cannot be changed while a program is running.

Variables

- Are data who can hold only one value at a time, but the value it holds can change.

Data type

- An item’s data type describes the type of data can be stored in it, how much memory the
item occupies and what types of operations can be performed on the data.

Data Type:

1. Primitive ( byte, short, int, long, float, double, char, Boolean)

2. Reference classes,arrays, strings etc.., which stores references data than the actual data.

Declaring Variables

- A variables is a statement that reserves a named memory location and includes the
following:

Data Type
Identifier
Optional assignment operator and assigned value
Semicolon
ex.., int myAge;

Declaring constants

- A constant is a memory location whose value does not change.

A keyword “final” Assignment operator & assigned value

Data type Semicolon


Identifier final int TAX-RATE = 12;

Integer Data Types


byte – 128 to 127 ( 1 byte)

short - 32,768 to 32767 ( 2 bytes)

int – 2,147, 483,648 to 2,147,483,657 ( 4 bytes)

long – 9,223 (billion) (8 byte)

The data types bytes, short, long, are variation of integer data types.

Byte and Short – less memory (smaller value)

Samples: byte aByte = 126;

Short aShort = 31999; or 31_999;

Depicts comma

Floating point data types

- Contains decimal position. (floating point number)


- Java support two floating point data types: float & double
- Float (4 bytes) – 6 or 7 significant digits of accuracy
- Double (8 bytes) – More memory. 14 or 15 significant digits of accuracy

Ex..,

Float grades = 89.5432F; To work


Boolean Data types

Operator:

< less than <= less than or equal to

>greater than >= greater than or equal to

== equal to != not equal to

Performing Arithmetic

Operator

+ Addition * Multiplication %modulus

-Subtraction /Division

String types

- Data at String types can hold values such as series of characters, words, sentence etc…,

final int QUARTZGALLON = 4;

int givenquatrz = 18;

int gallon, quartz;

gallon = givenquartz / QUARTZGALLON;

quartz = givenquartz % QUARTZGALLON;

Arithmetic Operations

- A mathematical operations used to perform calculation.


Operator: Addition, Subtraction, Multiplication, Division, and Modulus
Operators Precedence

- Refers to the rules for the order in which parts of a mathematical expressions are
evaluated.

Operators:

/ * % Higher

+- Lower

Associativity

- Evaluated from left to right.(Regardless of precedence)


int answer, x, y, z; int answer, x, y, z;
answer = x+y+z; answer = x+y*z;

Operator Precedence

int result = (2+3) *4; int result = 2* (3+(4*5));


= (5)*4; = 2* (3+(20));
= 20 = 2* (23);
= 46

Arithmetic Statements Efficiently

float tax = .10;


float insurance = .5;
float salary = 3000;

taxed = salary * tax;


insded = salary * insurance;
total = taxed + insded;
finalsalary = salary – total;

Type conversion
- Process of converting one data type to another
Data type
Unifying Type

- Is the type to which all operands in expression are converted so that they are
compatible with each other.

Implicit Conversion ( Java Performs)

- Automatically converts nonconforming operands to unifying type


- Also called promotions

Double highest

Float

Long short & byte int when used in expressions

Int lowest

Explicit Conversion

- Purposely overriding the unifying type imposed by java by performing a type cast

Type Casting
- Forces a value of one data type to be used as a value of another type

Cast Operator (to perform type cast)


- Created by placing the desired result type in parenthesis

Ex..,
float myMoney = 47.82f;

int dollars = (int) myMoney; result

dollars = 47
Accepting Input from user (KB)
- To create interactive programs that accept input from a user, you can use System.in
which refers to the standard input device. (keyboard)

Creating Scanner Object

In the library;

import java.util.Scanner;

in the block;

Scanner input Device = new Scanner (System.in);


“F” is used in Constant

Scanner Class methods


nextDouble(); nextFloat();

nextInt(); nextLong();

nextLine(); (Next line of data\ String)

next(); (complete token String) “L” is used in Constants

nextShort();

nextByte();

Methods

- The operation for a class is called methods; it is used to set the valued if the data,
retrieve the current values of the data, and perform other class- related functions on the
data
- A method is a program module that contains a series of statements that carry out a task
Method Calls and Placement

- To execute a method, you invoke or call it. In other words, a calling method makes
a method call, and the method call invokes a called method. The calling method is
also known as a client method because a called method provides a service for its
client

public class First {

public static void main(String [] args) {

displayAddress();

Method System.out.println(“First Java application “ );


Headers
}

public static void displayAddress() Method


Bodies
{

Sytem.out.Println(“ XYZ Company”);

Sytem.out.Println(“ 8900 U.S. hwy 14”);

Sytem.out.Println(“ Crystal Lake, IL 60014”);

Method Construction ;

Access Specifiers

Return Type

Method Name

Parenthesis

Adding Parameters to methods

- Data items you use in call to a method are called arguments. When the method
receives the data items, they are called parameters. Method that receives data are
flexible because they can produce different results depending on what data they receive.

You might also like