NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

ITPF

OOP POP
- uses classes and objects to create models based on the real world environment.
-follows a step-by-step approach to break down a task into a collection of variables and routines (or subroutines) through a sequence of instructions
- the program is divided into small chunks called objects which are instances of classes.
- program is divided into small parts based on the functions and is treated as separate program for individual smaller program
- access modifiers: Private, Public, and Protected. - no such modifiers
- data hiding is possible and hence it is more secure than POP. - is less secure as compare to OOPs
- less complex and hence new data objects can be created easily from existing objects - there’s no simple process to add data in POP at least not without revising the whole program.

JAVA
- first introduced by Sun Microsystems
- acquired by Oracle in 1995.
- first name was Oak.
- develop by James A. Gosling
- collaborated with Netscape Navigator’s Java Virtual Machine (JVM)
- Java adapted the syntax of c++
-Write Once, Run Anywhere (WORA)
- as object oriented programming language
program - collection of objects that communicate via invoking each other's methods.
- all programs are made of entities representing concepts or physical things known as “objects”.

Class
- template/blue print
- describes the behaviors/states that object
Object
- represents an entity in the real world that can be distinctly identified.
- have states and behaviors.
Three characteristics:
 State: represents the data (value) of an object.
 Behavior: represents the behavior (functionality) of an object
 Identity: An object identity is typically implemented via a unique ID.
Methods
- A method is basically a behavior.
Attribute
- A characteristic/s that describes an object.
Instance Variables
- Each object has its unique set of instance variables.


JAVA PROGRAMMING LIFE CYCLE
1.Writing Code
2.Compiling Code
3.Executing Application

Case Sensitivity
- Java is a case sensitive



NAME CONVENTION
Class Names
- first letter should be in Upper Case. each inner word’s first letter should be in Upper Case.
Example class: MyFirstJavaClass

Method Names
- should start with a Lower Case letter.
Example: myMethodName()

Constant Names
- All constant names written in Upper Case.

Program File Name
- Name of the program file should exactly match the class 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
1. All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_).
2. After the first character, identifiers can have any combination of characters.
3. A keyword cannot be used as an identifier.
4. Most importantly identifiers are case sensitive.

Java Modifiers
1.Access Modifiers
- default, public, protected, private
2.Non-Access Modifiers
- final, abstract

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

Java Arrays
Arrays
- store multiple variables of the same type.

PRINT METHODS IN JAVA
System.out.print(“”);
- print literals on single line
System.out.println(“”);
- print literals providing new lines

Escape Sequence in Java
- A character preceded by a backslash () is an escape sequence and has a special meaning to the compiler.

COMMENTS
- used to explain Java code to make it more readable.

Single-line Comments
- start with two forward slashes (//).

Multi-line Comments
- start with /* and ends with */.




BASIC STRUCTURE OF A JAVA PROGRAM

PACKAGE DECLARATION
- can be placed in different directories/packages
- a path from source directory is considered as package declaration.

IMPORT STATEMENTS
- tells the compiler where to look to find classes that you refer to in your code.

COMMENTS
CLASS DEFINITION
- It defines the information about the user-defined classes in a program.
- A name should be given to a class in a java file. This name is used while creating an object of a class, in other classes/program.

MAIN METHOD CLASS
- where the execution actually starts
- Its an entry point for the class or program

//simple application
public class SampleProgram{
public static void main(String[] args)
{
//your code here
}
}

CONSTANT AND VARIABLES
- memory location that can store a value.

CONSTANT
- value cannot be changed while a program is running

DECLARING NAMED CONSTANT
includes the ff;
1. A keyword final
2. data type
3. An identifier
4. An assignment operator and assigned value
5. An ending semicolon

final int TAX_RATE = 12;

VARIABLE
- hold only one value at a time, but the value it holds can change

DECLARING VARIABLES
- a variable is a statement that reserves a named memory location and includes the ff;
1. A data type
2. An identifier
3. An optional assignment operator and assigned value
4. An ending semicolon

int myAge;
Int myAge = 21;





DATA TYPE
- type of data that can be stored in it

1. PRIMITIVE

byte Byte-length integer
short Short integer
int Integer
long Long integer
float Single-precision floating point
double Double-precision
char Single character
boolean Boolean value (true or false)

2. NON PRIMITIVE/REFERENCE

Strings
- sequence of characters
Arrays
- can store one or more values of a specific data type
Classes
- blueprint which includes all your data
- contains (variables) and methods to describe the behavior of an obejct.

DIFFERENCE BETWEEN PRIMITIVE AND NON PRIMITIVE
PRIMITIVE NON PRIMITIVE
Predefined in Java Created by the programmer and is not defined by Java
Cannot used to call methods to perform certain operations Can be used to call methods to perform certain operations
Always has a value Can be null
Starts with a lowercase letter Starts with an uppercase letter
Size depends on the data type Have all the same size

Integer Data Types
byte and short (less memory and smaller value.
long (more memory and larger values)

Floating-point Data Types
- contains decimal
float - up to six or seven digits
double - more than a float, 14 or 15 digits

boolean Data Types
- can hold only one of two values - true or false.

Operator Description
< Less than
> Greather than
= Equal to
<= Less than or equal to
>= Greater than or equal to
!= Not equal to

Char Data Types
- Hold any single character
- Place constant character values within single quotation marks ‘ ‘
char middleInitial = ‘M’;
char aStar = ‘*’;
String Types
- Hold values such as series of characters, words, sentence etc.
String message = “Hello everything”;

PERFORMING ARITHMETIC
Operator Description
+ addition
- subtraction
* multiplication
/ division
% remainder(modulus)

OPERATOR PRECEDENCE
- rules for the order in which parts of a mathematical expression are evaluated.
Operators precedence
* / % higher
+ - lower




TYPE CONVERSION
- process of converting one data type to another.

UNIFYING TYPE
- all operands in an expression are converted so that they are compatible with each other.

IMPLICIT CONVERSION
- it automatically converts nonconforming operands to the unifying type.
- also are called promotions.

Example:
int hoursWorked = 37;
double payRate = 16.73;
double 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.

Example:
double bankBalance = 189.66;
float weeklyBudget = (float) (bankBalance / 4);

ACCEPTING INPUT FROM A USER (KEYBOARD)
- To create interactive programs that accept input from a user, you can use System.in.

System.in
- refers to the standard input device

CREATING A SCANNER OBJECT
In the library:
import java.util.Scanner;
In the block:
Scanner inputDevice = new Scanner(System.in);

PASSING THE USER-INPUT TO A VARIABLE
Scanner inputDevice = new Scanner(System.in);
int num1 = inputDevice.nextInt();







METHODS
- operation for a class
- used to set the valued of the data, retrieve the current values of the data, and perform other class-related functions on the data.
- contains a series of statements that carry out a task.

METHOD CALLS AND PLACEMENT
execute - you invoke or call it.
- calling method makes a method call
method call invokes a method
calling method
- also known as a client method, provides a service for its client.

METHOD CONSTRUCTION
 Access Specifiers
 Return Type
 Method Name
 Parenthesis

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.