Fanatah Java Academy

Fanatah Java Academy LEARN JAVA FROM SCRATCH.! No matter your background or age, it is not too late to learn computer programming.

And we are the experts in java training that can help you become a professional developer in no time. Fanatah's Java Academy is a java training Centre located in Harare that offers java computer programming- OCPJP SE(Oracle Certified Professional Java Programmer-Standard Edition ). This is an international certification offered by Oracle University.. Java Developers are amongst the most paid softw

are engineers and a java certification serves to prove your competence and therefore it is one of the most prestigious and sought after IT certifications world-wide. For more info visit our website:
www.fanatah.com/java-training

Fanatah Java Academy for all your Java Training from the best computer school in the region.
08/02/2022

Fanatah Java Academy for all your Java Training from the best computer school in the region.

*INHERITANCE**BY FANATAH | UNDER - JAVA FOR COMPLETE BEGINNERS*Inheritance is the process where one class acquires the p...
15/08/2020

*INHERITANCE*

*BY FANATAH | UNDER - JAVA FOR COMPLETE BEGINNERS*

Inheritance is the process where one class acquires the properties (methods and fields) of another.

The class which inherits the properties of other is known as subclass (derived class, child class) and the class whose properties are inherited is known as superclass (base class, parent class).

*extends Keyword*

'extends' is the keyword used to inherit the properties of a class. The syntax of extends keyword is as follows:

*Syntax*

class Super { ..... ..... }
class Sub extends Super { ..... ..... }

*Sample Code*

Here is an example demonstrating Java inheritance. In this example, there are two classes namely Calculation and MyCalculation.

Using extends keyword, MyCalculation inherits the methods addition() and Subtraction() of the Calculation class.

You can copy and paste the following program in a file with name MyCalculation.java & run it...

*Example*

class Calculation {
int z;
public void addition(int x, int y) {
z = x + y;
System.out.println("The sum of the given numbers:"+z);
}
public void subtraction(int x, int y) {
z = x - y;
System.out.println("The difference between the given numbers:"+z);
}
}

public class MyCalculation extends Calculation {
public void multiplication(int x, int y) {
z = x * y;
System.out.println("The product of the given numbers:"+z);
}
public static void main(String args[]) {
int a = 20,
b = 10;
MyCalculation demo = new MyCalculation();
demo.addition(a, b);
demo.subtraction(a, b); demo.multiplication(a, b);
}
}

After executing the program, it will produce the following;

*Output*

The sum of the given numbers:30
The difference between the given numbers:10
The product of the given numbers:200

In the above program, when an object of *MyCalculation* class is created, a copy of the contents of the superclass is also created within it.
That is why, using the object of the subclass you were able to access the members of a superclass.

N.B A superclass object / reference variable can only access the members of the superclass, but a subclass object can access both subclass and supercalss members.
That is why it is better for you to generally create an object/reference variable of the subclass.

*Note* Constructors are not members, so they are not inherited by subclasses, but the constructor of the superclass can be invoked from the subclass.

*The super keyword*

The *super* keyword is similar to *this* keyword.
Here are the instances where the super keyword is used.

1. )
It is used to *differentiate the members* of superclass from the members of subclass, if they have same names.

2. )
It is used to *invoke the superclass* constructor from subclass.

*Differentiating the Members*

If a class is inheriting the properties of another class. And if the members of the superclass have the names same as the sub class, to differentiate these variables we use super keyword as shown below.

super.variable
super.method();

**BECOME A PROFESSIONAL ORACLE JAVA PROGRAMMER TODAY..**________________________Fanatah Java Academy, are professional t...
12/07/2020

**BECOME A PROFESSIONAL ORACLE JAVA PROGRAMMER TODAY..**
________________________

Fanatah Java Academy, are professional tutors of Java Programming from the very beginning up to professional level.
No matter your background or age, it is not too late to learn computer programming..(Starting with Java because it is easy to learn..).

8 Topics • 4 weeks • 40hrs

Whether you are a beginner or intermediate programmer, this course is perfect for you and will male you an expert in no time.

The 4 week course will equip you with skills to write java programs and android apps of your own.
With practical programming lectures and hands on coding exercises & theory needed for Oracle Certification Exam.

Call/App : 0772 908 505.
Email : [email protected]

JAVA BEGINNERINTRODUCTION TO JAVA.LESSON 1 : CHAPTER 2By FanatahHOW TO RUN YOUR FIRST JAVA PROGRAM -BY FANATAH | UNDER: ...
08/07/2020

JAVA BEGINNER

INTRODUCTION TO JAVA.

LESSON 1 : CHAPTER 2

By Fanatah

HOW TO RUN YOUR FIRST JAVA PROGRAM -

BY FANATAH | UNDER: LEARN JAVA FROM SCRATCH -BEGINNER A.

In this tutorial, we will learn how to write, compile and run a java program. We will also learn about java syntax, code conventions and several ways to run a java program.

Simple Java Program:

public class Welcome {

public static void main(String [ ] args) {

System.out.println("Hello.");

System.out.println("Welcome to programming in java.");

}//End of main

}//End of FirstJavaProgram Class

Output: Hallo.
Welcome to programming in java.

How to compile and run the above program

NB. Required: You need to have java installed on your machine. You can download get the java jdk 1.8 or laterfreely online. Or Netbeans version 8 or later.

There are 2 main methods of running a Java Program:
1. Using command prompt(cmd).
2. Opening and running on Netbeans IDE or Eclipse.

1. CMD Way:

Step 1: Open a text editor, like Notepad on your Windows Machine.
Copy the above program and paste it in the text editor.

Step 2: Save the file as Welcome.java. You may be wondering why we have named the file as Welcome.?
This is because of the rule that you should always make the file-name the same as the public class name. In our program, the public class name is Welcome, and that’s why our file name should be saved as Welcome.java.

Step 3: In this step, we will compile the program. For this, open command prompt or just type the words (cmd) on your start menu of you Windows-machine.

Before you compile your program create a folder in C/ drive manually by right clicking then selecting new folder and save it as MyJavaExamples and make sure that is where you will be saving all your java programs when u are in notepad.
Now compile your program, by typing the following commands and hit enter:

cd\

cd MyJavaExamples

javac Welcome.java

You may get this error when you try to compile the program: “javac’ is not recognized as an internal or external command, operable program or batch file“. This error occurs when the java path is not set in your system

If you get this error then you first need to set the path before compilation.

Set Path in Windows:
Open command prompt (cmd), go to the place where you have installed java on your system and locate the bin directory, copy the complete path and write it in the command like this.

set path=C:\Program Files\Java\jdk1.8.0_121\bin

Note: Your jdk version may be different. Since I have java version 1.8.0_121 installed on my system.

That’s it.

The steps above are for setting up the path temporary which means when you close the command prompt or terminal, the path settings will be lost and you will have to set the path again next time you use it. I will share the permanent path setup guide in the later tutorial.

Step 4: After compilation the .java file gets translated into the .class file(byte code). Now we can run the program. To run the program, type the following command and hit enter:

java Welcome

Note that you should not append the .java extension to the file name while running the program.

Closer look to the First Java Program

Now that we have understood how to run a java program, let us have a closer look at the program we have written above and try to break it down.

public class Welcome {

This is the first line of our java program. Every java application must have at least one class definition that consists of class keyword followed by class name. When we say keyword, we mean a word that should not be changed, we should use it as it is.
However the class name can be anything you choose to name it.

I have made the class public by using public access modifier, I will cover access modifiers in a separate tutorial, all you need to know for now is that a java file can have any number of classes but it can only have one public class and the file name you save should be name of the public class.

public static void main(String[ ] args) {

This is our next line in the program, lets break it down to understand it:

public:
This makes the main method public that means that we can call the method from outside the class.

static:
We do not need to create object for static methods to run. They can run itself.

void:
It does not return anything.

main:
It is the method name. This is the entry point method from which the JVM runs your program.

(String[] args):
Used for command line arguments that are passed as Strings. We will cover that in a separate lesson.

System.out.println("Hallo. Welcome to Java Programming.");

This method prints the contents inside the double quotes into the console (screen/monitor) and inserts a newline after.

JAVA BEGINNER LESSONSCHAPTER 1*Introduction to Java Programming*By Fanatah.Java Master Class Course- Learn Java From Scr...
08/07/2020

JAVA BEGINNER LESSONS

CHAPTER 1

*Introduction to Java Programming*

By Fanatah.

Java Master Class Course- Learn Java From Scratch.!!

JAVA Programing Language was developed by Sun Microsystems in 1991, but was later acquired by Oracle Corporation. It was developed by James Gosling and Patrick Naughton who were the lead programmers in the group.
It is a simple programming language and it is easy to learn.
Writing, compiling and debugging a program is also easy in java especially whem using and IDE such as Netbeans.

It was called Oak at 1st but the name was not catchy and neither was the market ready for it but after renaming it to Java ( the coffee that most of the programmers were drinking when they developed the language) the name took off and so did the language.

*Terminology Used In Java*

Before one starts learning Java, they need to be familiar with common java terms so as to understand the language.

*Java Virtual Machine (JVM)*
When you write a java program, you then save it and then compile the program and the last stage is called running the program.

1) Writing of the program is of course done by java programmer like you and me.
2) Compilation of program is done by javac compiler, javac is the primary java compiler included in java development kit (JDK). It takes java program as input and generates java bytecode as output. (known as a .class file).

3) In the third phase, the JVM executes the bytecode generated by compiler. This is called running the program phase.

Now we understand that the primary function of JVM is to execute the bytecode produced by the compiler.

*Each operating system has a different JVM, however the output they produce after ex*****on of bytecode is same across all operating systems.*

That is why java is popularly referred to as a platform independent language.

*bytecode*
Bytecode is code that is converted into binary form. It is the java compiler inside the JDK that compiles your java source code into bytecode so that it can be executed by the JVM.
This bytecode is saved in a file known as a .class file by the compiler.

*Java Development Kit(JDK)*
Whien explaining JVM and bytecode, we used the term JDK. Let’s discuss the JDK:
As the name suggests this is a complete java development kit that includes JRE (Java Runtime Environment), compilers and various tools like Java Debugger and Java Documentation - (index of all java classes methods n interfaces found in that particilar java version), etc.

In order to create, compile and run a Java program you need a JDK installed on your computer or machine.

*Java Runtime Environment(JRE)*
JRE is a part of JDK which means that JDK includes JRE.
When you have JRE installed on your system, you can run a java program however you won’t be able to compile it. JRE includes JVM, browser plugins and applets support.
When you only need to run a java program on your computer, you would only need JRE.

These are the basic java terms that confuse a lot of beginners in java. Find time to study them and look them up on the internet if you ddnt quite get the definitions listed here.
Also through practise you will learn which is which, programming is like driving a manual car which you can only grasp full through a lot of practise.!!

For complete java glossary refer this link:
https://docs.oracle.com/javase/tutorial/information/glossary.html

*Some of the Main Features that set Java apart from other Programming Languages: *

*1. Java is a platform independent language*

Compiler(javac) converts source code (.java file) to the byte code(.class file). As mentioned above, JVM executes the bytecode produced by compiler. This byte code can run on any platform such as Windows, Linux, Mac OS etc. Which means a program that is compiled on windows can run on Linux and vice-versa. Each operating system has different JVM, however the output they produce after ex*****on of bytecode is same across all operating systems. That is why we call java as platform independent language.

*2. Java is an Object Oriented language*

Object oriented programming is a way of organizing programs as collection of objects, each of which represents an instance of a class.

4 main concepts of Object Oriented programming are:

Abstraction

Encapsulation

Inheritance

Polymorphism

*3. Simple*

Java is considered as one of simple language because it does not have complex features like Operator overloading, Multiple inheritance, pointers and Explicit memory allocation.

*4. Robust Language*

Robust means reliable. Java programming language is developed in a way that puts a lot of emphasis on early checking for possible errors, that’s why java compiler is able to detect errors that are not easy to detect in other programming languages. The main features of java that makes it robust are garbage collection, Exception Handling and memory allocation.

Secure

We don’t have pointers and we cannot access out of bound arrays (you get ArrayIndexOutOfBoundsException if you try to do so) in java. That’s why several security flaws like stack corruption or buffer overflow is impossible to exploit in Java.

*5. Java is distributed*

Using java programming language we can create distributed applications. RMI(Remote Method Invocation) and EJB(Enterprise Java Beans) are used for creating distributed applications in java. In simple words: The java programs can be distributed on more than one systems that are connected to each other using internet connection. Objects on one JVM (java virtual machine) can execute procedures on a remote JVM.

*6. Multithreading*

Java supports multithreading. Multithreading is a Java feature that allows concurrent ex*****on of two or more parts of a program for maximum utilisation of CPU.

*7. Portable*

As discussed above, java code that is written on one machine can run on another machine. The platform independent byte code can be carried to any platform for ex*****on that makes java code portable.

INTRODUCTION TO JAVA TERMINOLOGY :by Fanatah -The JDK. Very soon we will need to run Java applications on our machine so...
08/07/2020

INTRODUCTION TO JAVA TERMINOLOGY :

by Fanatah -

The JDK.

Very soon we will need to run Java applications on our machine so we practically learn how to write our own programs.
For you to do that you need to download a java software kit called the JDK.

JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a software development environment which is used to develop java applications and applets. It physically exists. It contains JRE + development tools. (such as classes, interfaces & methods that help you build ur own programs).

Thes predefined built in resources of classes and interfaces come packaged neatly in folders called packages that are all stored in a larger folder called the API -Application Programming Interface.
To use them or borrow them for your own programs you must import them usung the keyword 'import'.

JDK has different versions released in different times by Oracle and that is the one that determines which java version you are using.
E.g JDK 1.8 means you are using and studying Java version 8 classes & interfaces.
JDK.1.11 means version 11.

The JDK contains a private Java Virtual Machine (JVM) and a few other resources such as an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc) etc. to complete the development of a Java Application.

It can be downloaded and installed seperately or comes as part of an IDE (integrated development kit) such as Netbeans, Eclipse or Intelij.

*NB If u dont have it already installed on your machine, please download it or just download and install Netbeans so that when write our 1st program you have the tools to run it.*

*Today's lesson*JAVA IDENTIFIERSBY FANATAH | UNDER JAVA BASICS.NB* This is a certification topic*All Java components req...
08/07/2020

*Today's lesson*

JAVA IDENTIFIERS

BY FANATAH | UNDER JAVA BASICS.

NB* This is a certification topic*

All Java components require names. Names used for classes, variables, and methods are
called identifiers.

E.g.
class Hallo{ }

class is a keyword.
Hallo is an identifier.

int x = 12;

int is a keyword.

x is an identifier.

In Java, there are several points to remember about identifiers.

They are as follows:
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.
1.A key word cannot be used as an identifier.

2.Most importantly, identifiers are case sensitive.
3.Examples of legal identifiers: age, $salary, _value, __1_value.
4.Examples of illegal identifiers: 123abc, -salary.

Java Modifiers:

Like other languages, it is possible to modify classes, methods, to provide or deny access to a thing., by using modifiers.

There are two categories of modifiers:

1. Access Modifiers: default, public , protected, private

2. Non-access Modifiers: final, abstract, strictfp.

NB* can someone tell us what strictfp means and where it can be applied..??

Java Variables:

Following are the types of variables in Java:

1. Local Variables

2. Class Variables (Static Variables)

3.Instance Variables (Non-static Variables)

JAVA BASICS : VARIABLES -By Fanatah.1. VariablesA variable provides us with named storage that our programs can manipula...
08/07/2020

JAVA BASICS :

VARIABLES -

By Fanatah.

1. Variables

A variable provides us with named storage that our programs can manipulate.
Each variable in Java has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.

You must declare all variables before they can be used.
The basic form of a variable declaration is shown here:
data_type variable = value;

Here data type is one of Java's datatypes and variable is the name of the variable. To declare more than one variable of the specified type, you can use a comma-separated list.

Following are valid examples of variable declaration and initialization in Java:
int a, b, c;
// Declares three ints, a, b, and c.

int a = 10, b = 10;
// Example of initialization

double pi = 3.14159;
// declares and assigns a value of PI.

char a = 'a';
// the char variable a iis initialized with value 'a'

Constant: During the ex*****on of program, value of variable may change. A constant represents permanent data that never changes.

If you want use some value likes p=3.14159; no need to type every time instead you can simply define constant for p, following is the syntax for declaring constant.
Static final datatype ConstantName = value;

Example: static final float PI=3.14159;

Lets discuss any challenge on this

2. Data type

Every variable in Java has a data type. Data types specify the size and type of values that can be stored.
Data types in Java divided primarily in two tyeps:
Primitive(intrinsic) and Non-primitive.

Primitive types contains Integer, Floating points, Characters, Booleans And Non-primitive types contains Classes, Interface and Arrays.

Integer:This group includes byte, short, int and long, which are whole signed numbers.
Floating-point Numbers: This group includes float and double, which represent number with fraction precision.
Characters: This group includes char, which represents character set like letters and number
Boolean: This group includes Boolean, which is special type of representation of true or false value.

Some data types with their range and size:
byte: -128 to 127 (1 byte)

short: -32,768 to +32,767 (2 bytes)

int: -2,147,483,648 to +2,147,483,647 (4 bytes)

float: 3.4e-038 to 1.7e+0.38 (4 bytes)

double: 3.4e-038 to 1.7e+308 (8 bytes)

char : holds only a single character(2 bytes)

boolean : can take only true or false (1 bytes)

3. Variable scope

There are three kinds of variables in Java:

Local Variable:
1. A variable that is declared inside the method is called local variable.
2. Local variables are created when the method, constructor or block is entered and the variable will be destroyed once it exits the method, constructor or block.
3. Access modifiers cannot be used for local variables.
4. Local variables are visible only within the declared method, constructor or block.
5. There is no default value for local variables so local variables should be declared and an initial value should be assigned before the first use.

Instance Variable
1. A variable that is declared inside the class but outside the method is called instance variable . It is not declared as static.
2. Instance variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed.
3. Instance variables hold values that must be referenced by more than one method, constructor or block, or essential parts of an object's state that must be present throughout the class.
4. Instance variables can be declared in class level before or after use.
5. Access modifiers can be given for instance variables.
6. Instance variables have default values. For numbers the default value is 0, for Booleans it is false and for object references it is null. Values can be assigned during the declaration or within the constructor.
7. Instance variables can be accessed directly by calling the variable name inside the class. However within static methods and different class ( when instance variables are given accessibility) should be called using the fully qualified name . ObjectReference.VariableName.

Class/static variables:
1. A variable that is declared as static is called static variable. It cannot be local.
2. Class variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block.
3. There would only be one copy of each class variable per class, regardless of how many objects are created from it.
4. Static variables are stored in static memory.
5. Static variables are created when the program starts and destroyed when the program stops.
6. Visibility is similar to instance variables.
7. Static variables can be accessed by calling with the class name ClassName.VariableName.

Example
class A{
int data=50;
//instance variable

static int m=100;
//static variable

void method(){
int n=90;
//local variable
}
}//end of class A

GENERAL ELEMENTS OF A JAVA PROGRAM. by Fanatah -When we consider a Java program, it can be defined as a collection of ob...
08/07/2020

GENERAL ELEMENTS OF A JAVA PROGRAM.

by Fanatah -

When we consider a Java program, it can be defined as a collection of objects that
communicate via invoking each other's methods. Let us now briefly look into what do class,
object, methods, and instance variables mean:

1.Object - Objects have states and behaviors. Example: A dog has states - color,
name, breed as well as behavior such as wagging their tail, barking, eating. An
object is an instance of a class.

2. Class - A class can be defined as a template/blueprint that describes the
behavior/state that the object of its type supports.

3. Methods - A method is basically a behavior. A class can contain many methods.
It is in methods where the logics are written, data is manipulated and all the
actions are executed.

4. Instance Variables - Each object has its unique set of instance variables. An
object's state is created by the values assigned to these instance variables.

Example of a First Java Program:

Let us look at a simple code that will print the words Hello World.

public class MyFirstJavaProgram {
/* This is my first java program.
* This will print 'Hello World' as the output
*/
public static void main(String []args) {
System.out.println("Hello World"); // prints Hello World
}
}

INTRODUCTION TO JAVA BASICS:JAVA SYNTAX -By Fanatah.When writing your Java programs, it is very important to keep in min...
08/07/2020

INTRODUCTION TO JAVA BASICS:

JAVA SYNTAX -

By Fanatah.

When writing your Java programs, it is very important to keep in mind the following points -

1. Case Sensitivity -
Java is case sensitive, which means
identifier Hello and hello would have different meaning in Java.

2. 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 in Upper Case.
Example: class MyFirstJavaClass

3. 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 Upper Case.

Example: public void myMethodName()

4. 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 append '.java' to the end of the name (if the file name and the
class name do not match, your program will not compile).

Example: Assume 'WelcomeToJava' is the class name.
Then the file should
be saved as 'WelcomeToJava.java' (without the quotes).

5.public static void main(String args[]) -
Java program processing starts from
the main() method which is a mandatory part of every Java program.

Java uses the 'this'  keyword which in other languages such as C & C++ works as a pointer but in Java it is just a keywo...
08/07/2020

Java uses the 'this' keyword which in other languages such as C & C++ works as a pointer but in Java it is just a keyword that refers to the current object..!!

Comments are necessary to help programmers understand the flow of any program written in Java..
08/07/2020

Comments are necessary to help programmers understand the flow of any program written in Java..

Address

102 Twentydales, Hatfield
Harare

Opening Hours

Monday 09:00 - 17:00
Tuesday 09:00 - 17:00
Wednesday 09:00 - 17:00
Thursday 09:00 - 17:00
Friday 09:00 - 17:00
Saturday 09:00 - 13:00

Telephone

+263772908505

Alerts

Be the first to know and let us send you an email when Fanatah Java Academy posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Contact The Business

Send a message to Fanatah Java Academy:

Share