0% found this document useful (0 votes)
7 views

Java T Point Notes-converted (4)

Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995, known for its platform independence and security features. It has various applications including desktop, web, enterprise, and mobile applications, and is supported by different platforms such as Java SE, EE, ME, and FX. Key concepts in Java include variables, data types, classes, and methods, which facilitate code reusability and organization.

Uploaded by

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

Java T Point Notes-converted (4)

Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995, known for its platform independence and security features. It has various applications including desktop, web, enterprise, and mobile applications, and is supported by different platforms such as Java SE, EE, ME, and FX. Key concepts in Java include variables, data types, classes, and methods, which facilitate code reusability and organization.

Uploaded by

ketang7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

What is JAVA?

Java is a high level, class based, Platform-independent, object-oriented and secure


programming language. Java was developed by Sun Microsystems (which is now the
subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Before
Java, its name was Oak. Since Oak was already a registered company, so James Gosling and
his team changed the Oak name to Java?

What is JAVA Platform?


Any hardware or software environment in which a program runs is known as a platform.
Since Java has a runtime environment (JRE) and API, it is called a platform.

What are the applications of JAVA?


1. Desktop Applications such as acrobat reader, media player, antivirus, etc.
2. Web Applications such as irctc.co.in, javatpoint.com, etc.
3. Enterprise Applications such as banking applications.
4. Mobile
5. Embedded System
6. Smart Card
7. Robotics
8. Games, etc

What are the types of JAVA applications?

1. Standalone application
2. Web based application
3. Enterprise application
4. Mobile application

What are the different JAVA platforms?

1. Java SE (Standard Edition)


2. Java EE (Enterprise Edition)
3. Java ME (Micro Edition)
4. Java FX

What are the feature/buzzwords of JAVA?


1. Simple: Java is very easy to learn. Its syntax mainly based on C++.
2. Object oriented: Java is object oriented programming language in which everything
is an object. Object oriented programming means software development and
maintenance in terms of some predefined rules. There are six main pillars of Java.
Objects, Class, Inheritance, Polymorphism, Abstraction and Encapsulation.
3. Platform Independent: Java is platform independent language. That means it can
be run on different platforms such as windows, Linux, Mac Os etc. Java has two
components, Runtime Environment and API (Application Programming Interface).
Java code is compiled by the java compiler and converted it into bytecode. This byte
code is platform independent hence java is platform independent language.
4. Portable: As we can carry the bytecode to another platform and run it on other
platform. Hence it is also portable in nature.
5. Secured: Java is secured language due to it doesn’t have explicit pointer and it also
run inside the virtual machine sandbox.
6. Dynamic: Java supports the dynamic loading of classes. That is classes are loaded
on demand. It also supports dynamic compilation and automatic memory
management.
7. Multithreaded
8. Distributed
9. High performance
10. Robust

How to set the path for Java?


1. Download java from official website and install it.
2. Open the path where you have install java. Generally open C drive – Program files –
java – jdk1.8 – bin and copy it.
3. Right click on my computer select properties.
4. Click on advanced system setting
5. Click on Environmental variables
6. Click on New under the user variables
7. Give the variable name as path and paste the copied data in variable path field.
8. Finally click ok and apply and finish.

What is the difference between JVM, JRE and JDK?


1. JVM: JVM Stands for Java Virtual Machine. JVM provides runtime environment in
which bytecode executed. It also runs the program written in the other languages
and compiled to java bytecode. JVM performs following main task: Load Code,
Verifies code, Execute Code and provide the runtime environment.
2. JRE: JRE stands for Java Runtime Environment. It is also called as Java RTE. It is
nothing but implementation of JVM. It is used to provide runtime environment. It
consists of set of libraries and other files which are required for the JVM.
3. JDK: JDK stands for Java Development Kit. It contains JRE + development tools. It
consists of JVM, loader, compiler, archiver and a documentation generator which
required for complete development of java application.

Variables:
Variables are nothing but piece of memory use to store information. One variable can
store single information at a time. To utilize variables in java programming language we need to
follow below steps:
1. Variable Declaration (Allocating / Reserving memory)
2. Variable Initialization (Assigning / Inserting value)
3. Variable Usage
Note: - According to all programming language dealing with information directly is not a good
practice. To overcome this problem variables are introduced. There are four types of the variable.
1. Local Variable: A variable declared inside the body of method or constructor is called as
Local Variable. It is also called as temporary variable. The scope of local variable is
within the block in which it is declared. The local variable cannot be ‘Static’ in nature.
2. Global Variable: A variable which is declared in the class but outside the method body is
called as Global variable. It is also called as Permanent Variable. Scope of global variable
is present within the class only. It cannot be ‘Static’ in nature. Global variables without
static word cannot be used in static methods. It is also called as Instance variable.
They are created when we create object by using new keyword and destroyed as we
destroy object. Instance variables have default values.
3. Static Variable: The variable used with Static keyword and declared in the class
body is called as Static variable. It is also called as Class variables. It is stored in
static memory.

Example of Local Variable

Example of Global Variable / Instance Variable / Non static Variable


Example of Static Variable

Fig. Types of Variables Combined

Data Types: Data types are used to represent which type of information we are going to use in
our program. Depending on the data type memory reservation for the variable is decided. As per
the syntax of variable declaration we have to declare its data type first.
Syntax : data_type variable_name = value;
Example: int a = 10;
There are two main types of data types: Primitive data type and Non-primitive data types.
1. Primitive data types: Those data types have fix memory size are called as Primitive data
type. There are total 8 primitive data types. Primitive data types are again divide into two
types.
Data types Size Range Default value Example
Byte 1 byte -128 to 127 0 byte b = 122;
Short 2 bytes -32768 to 32767 0 short s = 30000;
Int 4 bytes -2^31 to [(2^31)-1] 0 int I = 51000;
Long 8 bytes -2^63 to [(2^63)-1] 0 long m = 2147483650
Float 4 byte -3.4e38 to 3.4e38 0.0 float f = 34.1234;
Double 8 byte -1.7e308 to 1.7e308 0.0 double d= 914748.365
Char 2 bytes 0 to 65535 0 (Space character) char c = ‘a’;
Boolean N.A. Only true or false False boolean a= true;

Program on data types


2. Non-Primitive data types: Those data type which does not have fix memory size is
called as Non primitive data types. Examples of non primitive data types are String,
class, interface, arrays etc.

Objects: Entities which have state, behavior and identity is called as Objects. An object is
instance (result) of class. For example, chair, pen, table, dog. Dog has his own name, color
that comes under the state and barking, running comes under behavior. Entity may be
logical and physical.
Class: Class is a blueprint from which we can create objects. It is logical entity. I cannot be
physical entity. It is group of common objects. Class in java consists of blocks, methods,
variables, interface etc.
Methods: A method in java is a block of code or collection of statements used to perform a
specific operation. It is used to achieve the reusability of code. We can write method once
and use it again and again. It is a block of code which runs when we call it.
Method signature () is used to pass the parameter to the method.
Syntax for method declaration: access modifier return type method name()
Example: public void add() { method body }
Methods are mainly divided into two types. Pre-defined methods and user defined methods
1. Predefined Methods: Methods which are already defines in java class libraries are
called as Pre-defined methods. These methods cannot be modified. Main method is one
of the best examples of predefined method. JVM always start executing code from main
method. Length(), equals(), sqrt() these are the examples of pre-defined methods.
2. User Defined methods: Methods which are written by the user or programmer is called
as User defined methods. These methods can be modified as per the requirement.
3. Static Method: The method which is created by using static keyword and belongs to
class is called as Static Method. We can call static method without creating object.
Syntax: class_name.method_name(); example: sample1.m1();
4. Non-Static method: It is also called as Instance method. To call these methods we have
to create an object of the class.
Syntax: class_name variable_name = new class_name();
Variable_name.method_name();
1. Static method calling from same class

2. Static method calling from different class:


3. Non static method calling from same class:

4. Non static method calling from different class:

5. Methods with parameter:


6. Methods without parameter:

7. Methods with and without parameter:

You might also like