0% found this document useful (0 votes)
23 views11 pages

Java Lessone One Document, Begginer Course

Java is a high-level programming language that is both compiled and interpreted, developed by Sun Microsystems, and is based on Object-Oriented Programming (OOP) principles. Key OOP features include encapsulation, abstraction, inheritance, and polymorphism, with classes and objects serving as foundational concepts. The document also covers variables, methods, if statements, and basic syntax for programming in Java.

Uploaded by

mdsiyenga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views11 pages

Java Lessone One Document, Begginer Course

Java is a high-level programming language that is both compiled and interpreted, developed by Sun Microsystems, and is based on Object-Oriented Programming (OOP) principles. Key OOP features include encapsulation, abstraction, inheritance, and polymorphism, with classes and objects serving as foundational concepts. The document also covers variables, methods, if statements, and basic syntax for programming in Java.

Uploaded by

mdsiyenga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java,

What is Java …… a Programming language

High level languages .. Written as normal English words … Java, Python, C++
Low level languages .. Close to binary numbers, or it could be binary numbers .
Assembly, Binary

Compiler/Interpreter .. Converting a high level language to a low level


language
(Translator for you and your computer)

Compiler vs Interpreter

Interpreter …..Only reads and executes code line by line

Step1 …Take eggs …..Execute…(Do Command)


Step2 …milk …..Execute…..(Do Command)
Step3 …Close bread …….Execute …..(Do Command)

Compiler ….. Reads all the code, then translates the whole code into machine
code after, then executes.

Step1 …Take Bread ……..Store in memory


Step2 …Put jam on bread ……….Store in memory
Step3 …Close Bread ……..Store in memory

Execute ….Do the command

Nothando … Interpreter
Recipe book

Nomfundo … Compiler

IDE

Integrated Development Environment


A software program that will store all the tool required for you to write and
execute code.
 Code Editor
 Helps Debug code
 Highlights errors
 Compiles or interpret your code
 Offers project management
 Provides terminal to run your code

What is Java

Java is a highlevel language, It is Compiled and interpreted at the same


time. And it is based on the OOP concept.
It was developed By the Sun MicroSystems team

OOP
Object, Orientated, Programming ….Language
Class
Class… Is a blueprint or template to create objects

Methods is a block of code that performs a specific task when called

Object This is an instance of a class

OOP
Key features/points in OOP

 Encapsulation
When we bundle code together into a single unit

 Abstraction
Hiding complex codes and details to only show what is necessary

 Inheritance (Twins)
When one class or method is able to inherit/Transfer its characteristics to
another class or method

 Polymorphism (Sibling)
When one class or method is able to inherit/Transfer its characteristics to
another class or method but being able to slightly change that feature

 Classes and objects


Discussed above

 Modularity
Code is divided into independent modules, to make it easier to debug and
maintain and scale
Variables
A Container for storing data values

String…… Words and sentences … 0 ….


Integer ….. Whole number from -Inifity to positive infinity … -3, -2 …. 3, 5 , 10

Float …… Decimal values …. Always ends with “f” ….eg.. 34.23f …. 1,345323f
…. 384,24f
Double … Decimal values …. 34.23
Boolean .. Stores a True or False
Character … Stores a single letter or symbol ‘f’,,, ‘&’ ‘#’…’$’

Declaring a variable

String name;
name = “Destiny”;

Eg… String name = “Destiny”;


Eg … Int age = 16;
Eg … Double money = 223.374;
Eg … Float accountChange = 2.34f;
Eg…. Boolean isStudent = false;
Eg… char add = ‘+’;

Challenge is to declare a variable for your name and your bank balance and print
out a sentence using [Link]

Your sentence must say : Hi guys my name its: name and I have balance in my
bank account.

String CharacterName
Int charLevel
Double Speed rate

boolean isCitizen = false;

char rank = ‘C’;

Methods
Void …….
We declare it and then we give it a function

In the main method we call it


Then executes its function

Return

public static String name( ){


int a = 3;
int b = 4;

int ans = a + b;

return ans
}
If Statements

Imagine your program has a decision to take

If something is true
It does a certain action

And

If something is not true


It does a certain action
Int age;
Age = 3;

If the age is greater than 3

Basic Syntax

if (age > 3) {
[Link](“the age is greater than 3”);
} else {
[Link](“the age is not greater than 3”);
}

Destiny is trying to host a diddy party (A legal one)

For anyone to enter the party, they must be older than 18…… help destiny

Write a dual alternative if statement to check if a person’s age is greater than 18


If it is, they are allowed to enter the party ….print it out using a system. Out
If not , they are not allowed to enter the party ….. print it out using a system. Out

else {// if condition is not true


Code
}
Comparing operators

== This checks if the value on the left is equal to the right…. Equals to ?
!= This checks if the value on the left is NOT equal to the right… Does not Equal
> or >= This checks if the value on the left is Greater than the value on the
right.. Greater than
< or <= This checks if the value on the left is Less than the value on the
right.. Greater
Nested if statement

if ( condition ){// if age is greater than 13


if ( condition) {
}
} else {// if condition is not true
Code
}
If age == 18 {
Code
}else {
Code
}
Number%2 if 0
1
9%2 0
7%2 0
14%2 0
4%2 0
6%2 0
And ………. &&
Or …………. ||

If( 3>4 or 3 == 3 ){
False true
………true

You might also like