Java Programming
Java Programming
SYLLABUS
Programming Fundamentals
Variables
Data types
Operators
Conditions
Loops
Methods
Object-Oriented Programming
Concrete Classes
Objects
Abstraction
Encapsulation
Inheritance
Polymorphism
Exceptions
Abstraction Classes
Interfaces
File I/O
Why Learn JAVA
Program (Software)
Programming Languages
Machine Language
Assembly Language
Machine dependent.
Introduced keyword | add,sub,..
To add 2 and 3 and get the result: add 2,3,result
A program called ‘assembler’ translates assembly code
to machine code.
Assembler
High-Level Language
Compiler
SOURCE PROGRAM->EXECUTABLE
Interpreter
Statement-INTERPRETER->OUTPUT
About Java
Editions of java
JDK
Anatomy of Java
Class Structure
‘class’ is a keyword(syntax).
Method
Examples:
Method Structure
Calling a method
Public
Private
Protect
Default
Naming Conventions
->ThisIsAName
->thisIsAName
->this_is_a_name
Package
Strings
Examples:
Calling println()
What is System.out.?
Numbers
Examples: 0,-19,129,-0.5,90.81
Arithmetic operators
Addition operator: +
Subtraction operator: -
Division operator: /
Multiplication operator: *
Comments
Write notes
Find errors
Access Modifier
Inside a class
Outside a class
Inside the package
Outside the package
Example: System.out
Return Types
getUserName();
-> Get te name of the user and return the value.
-> The return type is a text (String).
getUserAge();
-> Get the age of the user and return the value.
-> the return type is a number (int, double, …).
Examples:
printUserName();
-> We just want to print the name of the user.
-> we do not want to get any value from this method.
-> The return type is void.
Note that every method has a very specific role.
-> getUserName();
-> printUserName();
Command line arguments
1. Variables
2.Data types
Example:
Text.
Number.
Boolean.(true/false)
User defined types.(car,person,…)
3.Operators
5.Loops
While loop.
Do while loop.
For loop.
For each loop.
6.Methods
VARIABLES
3.Assignment
String myJob;
myJob = “programmer”;
Less error.
Less code.
More readable code.
Constants
Initializing constants
Indentifiers
Names of classes
Names of method
Names of variables
myName, myJob, sayName, Main, …
Naming rules
Example
Legal Illegal
1. $2 1. 2A
2. Person 2. a+b
3. Area 3. user name
4. Radius 4. int
5. Point 5. main
6. hello 6. System