Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views12 pages

Itpf Reviewer

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 12

ITPF REVIEWER

1 UNIT 1 BUT LIKE IM IN A RUSH VERSION

Java was created in 1995, by James Gosling, while he was working at Sun
Microsystems
First public release was in 1996.

Java is now currently held by Oracle.

Procedural Programs – Focuses on functions and does it in an ordered way to


operate data.
Object Oriented Programs/OOPs – Organizes code around objects, which
combine data and methods.

Object/s – Is an instance of a class, representing a specific entity with its own state
and behavior in a program

Class – Is a blueprint that defines the structure and behavior of (attribute and
methods) of objects.

Method – IS a function defined within a class that describes the behaviors or


actions an object can perform.

Attribute – are the data or properties associated with a class, defining the state or
characteristics of objects are created from that class(?) that’s what my notes say
LMAO

Instance Variable – is a variable defined in a class for which each object of the
class has its own unique copy, representing the object’s state.

Approach in Object oriented programming:


OOP/s access modifiers are introduced namely as private, public, and protected on
the other hand no such modifiers are introduced in POP/s (Procedural oriented
programming).

Security
Due to obstructions in OOPs, data hiding is possible and hence its more secure than
POPs

Complexity
OOPs due to modularity in its programs it is les complex and hence new data
objects can be created easily from existing objects, making object oriented easy to
modify.

2 UNIT 2 I HAVE NO IDEA WHAT IM DOING…

Class names – For all class names, the first letter should be in upper case. If
several words are used to form a name of the class, each inner word’s first letter
should be uppercase “MyFirstJavaClass”

Method names- All method names should start with a lower case letter. If several
words are used to form the name of the method, then each inner word’s first letter
should be in Uppercase. “myMethodName()”

Constant names – All constant names should be written in uppercase. If several


words are used to form the name of the constant, then put underscore between
words
“THIS_IS_A_CONSTANT” for const in Java, they use final.

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 (EXTENSIONS ARE THEIR NAME)
(if the file name and class name are not matching, it will not compile)
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.

No comment im lazy

Two categories of identifiers:


-Access modifiers: default, public, protected, private
-Non-access modifiers: final, abstract
Types of variables:
-Local variables
-Class variables (static variables)
-Instance variables(Non-static variables)

Arrays-
Are objects that store multiple variables of the same type. However, an array itself
is an object.
Reserved words for Java.

Escape sequences – A character preceded by a backslash (\) is an escape


sequence and has a special meaning to the compiler.

Single line comments – they are used to comment on code, they use two forward
slashes (//) NOT (\\)
Multi-line comments – they start with /* and ends with */.
Any text between /* and */ will be ignored by Java.

System.out.print(“”) – used to print literals on a single line


System.out.print(“”) – prints a new line after the value within the method is
printed. (think of it as endl or \n in C++)
3 UNIT 3 YEAAAAAAAA IM GOING INSANE

Basic structure of a Java program?


- Comments/Document section
- Package declaration
- Import statements
- Class definition
- Main method class
Document Declaration/Comment section
- The documentation section is an important section but optional for java
programs, (ill make it short its just to describe and add documentation to the
program, does really nothing within the code)
Package Declaration
- We declare packages
- Simply a container that groups related types
- It is necessary because a Java class can be placed in different packages and
directories based on the module they are used
Import statements
- Represents the class stored in the other package
- It is used to import the built-in and user defined packages, class or interface
in Java programming. (Like user inputs, things like that)
Ex. Import java.util.Scanner
^This is how you import the scanner class.

Constants – cannot be changed while program is running

Variable – can hold only one value at a time but it can change.
Just the same principle as the one we have for CC-103

ONE DIFFERENCE IS THE NON PRIMITIVE!

Non-Primitive/Reference Data type

- Strings – Is a sequence of characters, but in Java a string is an object that


represents a sequence of characters. Reference(??? Idk why maam just
added reference in the end, probably string is a reference ?? doesn’t make
sense to me T-T)

- Arrays – are homogeneous data structures as objects. That’s it.

- Classes – is a blueprint which incl- yeah this was said already at the
beginning of this reviewer come on.

Difference between the two:

- Primitive are predefined in Java.

- Non Primitive can be used to call methods

- Primitive type always has a value, non can be null

- Primitive type starts with a lowercase


- Size of a primitive type depends on the data type, non has all same size.

3.1 PART II

Arithmetic Operations
- + Addition
- - Subtraction
- * Multiplication
- / Division
- % Remainder (modulus)
Operator Precedence
- INSTEAD OF PEMDAS we have Operator Precedence, refers to the rules for
the order in which parts of a mathematical expression are evaluated.

IF THEYRE ALL THE SAME, it goes LEFT TO RIGHT.


Also parenthesis makes it higher, the program will calculate the math within the
parenthesis first.
Type conversion
- The process of converting one data type to another.
- Unifying type – is the type to which all operands in an expression are
converted so that they are compatible with each other
Two types of casting:
o Implicit type casting

o Explicit type casting

Implicit type casting


- The process of converting one data type to another.
Ex.
Int hoursWorked = 37;
double payRate = 16.83;
double grossRate = hoursWorked * payRate;

int hoursWorked = 37;


double grossRate = 16.83;
int grossPay = hoursWorked * payRate;
Explicit Type 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. To perform a type cast, you can use a cast operator, which is
created by placing the desired result type in parentheses.
o double bankBalance = 189.66;

float weeklyBudget = (float) (bankBalance /4);


System.in – standard input device (normally the keyboard)

Creating a Scanner object


In the library: import java.util.Scanner;
In the block(code): Scanner inputDevice = new Scanner(System.in);
Passing the user-input to a variable: int num1 = inputDevice.nextInt();
NOTE: inputDevice is the name/user-defined variable, you can just name it
to whatever really
Yea no comment.

4 JOPTIONPANE CLASS
Dialog Boxes
- Is a small graphical window that displays a message to the user or requests
input.
- A variety or dialog boxes can be displayed using the JOptionPane Class
- Two of the dialog boxes are:
o Message Dialog – a dialog box that displays a message

o Input dialog – a dialog box that prompts the user for input.

Using Import statement, how to state dialogs


- Import javax.swing.JOptionPane;
- Message Dialog – JoptionPane.showMessageDialog(null, “Hello world”);
(The hello world is just a thing to display what you can put there :3 don’t
forget that ( I will haunt you if you put hello world in the exams. )
- Input dialog – anyVariableHere = JOptionPane.ShowInputDialog(“ ”);
o Theres an OK button, Cancel button, and a textfield

System.exit() method – is called to end the dialog box/JOptionPane


o Requires a integer argument: System.exit(0);

NOTE: JOptionPane’s showInputDialog method always return the user’s


input as a STRING!!
But we can convert that, theyre called Parse Methods
o Byte.parseByte

o Integer.parseInt

o Short.parseShort

o Long.parseLong
o Float.parseFloat

o Double.parseDouble

5 LAST!!!! USING METHODS (WAIT… SHOULDN’T


THIS BE BEFORE JOPTIONPANE? IDK LEAVE ME
ALONE
Methods
- Operation for a class is called methods; it is used to set the values of the
data.
- Is a program module that contains a series of statements.
- Primary uses:
o Allows code reusability

o You can break complex program into a smaller chunks of code

o It increases code readability

o The public static void main is a method!!! Methods are just functions…
(in C++)
Adding parameters to Methods
- Arguments – are Data types you use in a call to a method.
o When the method receives the data items they are called
parameters. ( you can add more than one parameter )

Okay that’s it…


That’s all

You might also like