Java JDK - Unit 1-3
Java JDK - Unit 1-3
As you can see you have only JAVA RUNTIME not JAVA JDK, so you need to
install it by downloading it.
First of all you need to download and install
your java JDK to compile and run the codes
https://youtu.be/YhRagbmHLpU?si=qLqjqENUSy-ahZeP
https://code.visualstudio.com/
https://www.eclipse.org/downloads/
https://netbeans.apache.org/
Installing java on VSCODE
https://code.visualstudio.com/
Java is a programming language.
Java Tutorial Java is used to develop mobile apps, web apps,
desktop apps, games and much more.
Java Quickstart
In Java, every application begins with a class name, and that class must match the filename.
Let's create our first Java file, called P1_Hello.java, which can be done in any text editor (like
Notepad).
The file should contain a "Hello World" message, which is written with the following code:
Note: Java is
case-
sensitive:
"MyClass"
and
"myclass"
has different
meaning.
Unit1. Computer Programming,
numerical base systems (BIN, OCTAL,
HEX and DEC).
Before we start programming
D(23) = B(???)=O(???)=H(???)
Numerical system
Numerical system
Numerical system
Numerical system
OCTAL to Hexa (Vice versa)
EXERCISES(Choose at least two letters from each question): TASK TO BE DONE
1- Convert to the binary base the following numbers on a decimal basis: a) 72; b) 127; c) 35; d) 23; e) 165; f) 40; g)
22; h) 14
2- Convert to the decimal base the following numbers in binary basis: a) 100001; b) 11011; c) 1100100; d)
10000000; e) 11001011; f) 10110001; g) 10110001; h) 100110000
3- Convert to the octal base the following numbers on a decimal basis: a) 567; b) 983; c) 1020; d) 65; e) 680; f) 105;
g) 294; h) 679
4- Convert the following numbers to the Hexadecimal base on a decimal basis: a) 567; b) 983; c) 1020; d) 65; e) 680;
f) 105; g) 294; h) 679
5- Convert to the Octal base the following numbers in Hexadecimal basis: a) F5; b) AB7; c) 98A; d) F1E2; e) E229; f)
135; g) 710; h) CE1
6- Convert to Binary base the following numbers in Octal base: a) 3365; b) 752; c) 625; d) 13703; e) 67105; f) 2004;
g) 321; h) 7654
7- Convert to Octal base the following numbers in Binary basis: a) 1110101; b) 11110011; c)
1010011100101110111000; d) 111101110; e) 10101010101010; f) 111101001010; g) 110100010; h) 10111110011;
h) 10111110011
Example
byte myNum = 100;
System.out.println(myNum);
Short
The short data type can store whole numbers from -32768 to 32767:
Example
short myNum = 5000;
System.out.println(myNum);
Int
The int data type can store whole numbers from -2147483648 to 2147483647. In general, and in our
tutorial, the int data type is the preferred data type when we create variables with a numeric value.
Example
int myNum = 100000;
System.out.println(myNum);
Long
The long data type can store whole numbers from -9223372036854775808 to
9223372036854775807. This is used when int is not large enough to store the value. Note that
you should end the value with an "L":
Example
long myNum = 15000000000L;
System.out.println(myNum);
Float
The float data type can store fractional numbers from 3.4e−038 to 3.4e+038. Note that you
should end the value with an "f":
Example
float myNum = 5.75f;
System.out.println(myNum);
The double data type can store fractional numbers from 1.7e−308 to 1.7e+308. Note
that you should end the value with a "d":
Example
double myNum = 19.99d;
System.out.println(myNum);
Booleans
A boolean data type is declared with the boolean keyword and can
only take the values true or false:
Example
boolean isJavaFun = true;
boolean isFishTasty = false;
System.out.println(isJavaFun); // Outputs true
System.out.println(isFishTasty); // Outputs false
Mutable vs Immutable Objects
A mutable object can be changed after it's created, and an immutable object
can't.