Introduction to Java, classes and objects

What is flow chart?

    A flowchart is a type of diagram that represents a workflow or process. Also It can be defined as a diagrammatic representation of  any process.

Advantages of C language

➡ Speed of compilation is comparatively high
➡ Powerful and efficient language

Problems with C programming

➡ It is a structured Programming Language
➡ C is middle level language
➡ Does not offers the concept of Object oriented programming
➡ We have to write too long code for simple programs
➡ It is complex to understand.
➡ It is also complex to code.

Introduction to Java

It is a programming language created by James Gosling from Sun Microsystems(SUN). It is object oriented programming language.

java icon csegtu

Creator of java :- James Gosling


james Gosling credit : wikimedia

Where Java can be used?

➡ Mobile applications ( mainly android apps)
➡ Desktop applications
➡ Web servers and application servers
➡ Web applications and much more....

Advantages of using Java

➡ Works with different platform
➡ It is Platform independent
➡ one of the popular language in the world
➡ It is based on the concept of object oriented programming

Classes and Objects

A class may be thought of as a 'data type' and an object as a 'variable' of that data type. Once a class has been defined, we can create any number of objects belonging to that class.

Class is collection of objects of  similar type. They are user defined datatypes and behave like the built-in types of the programming language.

Objects are the basic runtime entities in an object-oriented system.

Let's understand with real-world example of car and fruit.

As Mango, apple, Orange etc. are different types of fruit. we can say it as like mango, apple, Orange etc. belongs to class of fruit.

same with Cars i.e. Mercedes, i10, Ferrari, etc. are members of class Car. 

Declaration of variable in C-
int a;

car Ferrari;
fruit mango;

car ➡ general
Ferrari ➡ specific

➡ classes are considered as data-types and object is considered as variables.

What does it mean by platform independency of a programming language?

➡ Platform independency means the program is not dependent on a particular system. It can  run on variety of platforms.

how java is platform independent?

Java compiler produces a unique type of code called bytecode unlike c compiler where compiler produces only natively executable code for a particular machine.

When the Java program runs in a particular machine it is sent to java compiler, which converts that code into intermediate code called Bytecode. This bytecode is sent to Java Virtual Machine which resides in the RAM of any OS. JVM converts the bytecode into native machine code. 

Here bytecode will be same for every system but the JVM will be different according to the system.

Comments

YouTube

Popular posts from this blog

GTU OOP Programs - 11

Mini project ideas for Operating System

GTU OS Program - 8