0% found this document useful (0 votes)
2 views4 pages

What is Java

Java is a high-level, platform-independent programming language created in 1995, known for its portability and security. It supports object-oriented programming concepts such as inheritance, polymorphism, and abstraction, and is widely used in various applications including mobile, web, and embedded systems. Key features include the use of variables, methods, and exception handling, with a focus on code reusability and clarity.

Uploaded by

saayandas1
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)
2 views4 pages

What is Java

Java is a high-level, platform-independent programming language created in 1995, known for its portability and security. It supports object-oriented programming concepts such as inheritance, polymorphism, and abstraction, and is widely used in various applications including mobile, web, and embedded systems. Key features include the use of variables, methods, and exception handling, with a focus on code reusability and clarity.

Uploaded by

saayandas1
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/ 4

What is Java?

Java is a widely-used, high-level programming language created in 1995 and owned by Oracle.
It is known for its portability, security, and object-oriented features. Java is used in a variety of
applications, including mobile (especially Android), desktop, web, server, and embedded
systems [1] .

What is a Variable?
A variable in Java is a container for storing data values. Variables must be declared with a
specific type, such as int, String, float, etc., and can hold data that can be changed during
program execution [2] .

Why is Java a Platform Independent Language?


Java is platform independent because Java programs are compiled into an intermediate form
called bytecode, which can be executed on any system that has a Java Virtual Machine (JVM).
The JVM interprets the bytecode for the underlying hardware, allowing the same Java program
to run on different platforms without modification. This concept is known as "Write Once, Run
Anywhere" [3] [4] .

Features of Java
Object Oriented
Platform Independent
Simple
Secure
Architecture-neutral
Portable
Robust
Multithreaded
Interpreted
High Performance
Distributed
Dynamic [4]
Applications of Java
Mobile applications (especially Android)
Desktop applications
Web applications
Web servers and application servers
Games
Database connectivity
Embedded systems [1]

What is a Method?
A method in Java is a block of code that performs a specific task and can be called to execute
from other parts of the program. Methods can take parameters, return values, and help organize
code for reusability and clarity.

What is a Local Variable?


A local variable is declared inside a method, constructor, or block, and its scope is limited to that
method or block. It is created when the method/block is entered and destroyed when it exits.
Local variables cannot be accessed outside their scope [5] .

What is a Global Variable?


A global variable in Java is typically a variable declared outside any method, usually as a static
member of a class. It can be accessed from any part of the program. Global variables can also
be defined in interfaces as public, static, and final by default [6] .

Final Network in Java


The term "Final network in Java" is unclear and not standard in Java terminology. If you meant
the final keyword, it is used to declare constants, prevent method overriding, or inheritance. If
you meant networking in Java, Java provides classes like Socket and ServerSocket for network
programming.

What is Polymorphism?
Polymorphism is an object-oriented concept where a single interface can represent different
underlying forms (data types). In Java, it allows objects to be treated as instances of their
parent class rather than their actual class, enabling method overriding and dynamic method
dispatch.
What is Abstraction?
Abstraction is the process of hiding the complex implementation details and showing only the
essential features of an object. In Java, abstraction is achieved using abstract classes and
interfaces.

What is Inheritance?
Inheritance is an object-oriented feature that allows one class (child/subclass) to inherit fields
and methods from another class (parent/superclass). It promotes code reuse and establishes a
relationship between classes.

Types of Inheritance in Java


Single Inheritance (one class inherits from another)
Multilevel Inheritance (a class inherits from a class, which in turn inherits from another class)
Hierarchical Inheritance (multiple classes inherit from a single parent class)
Note: Java does not support multiple inheritance (a class inheriting from more than one
class) directly to avoid ambiguity.

What is a Constructor?
A constructor is a special method in Java that is called when an object is instantiated. It has the
same name as the class and does not have a return type. Constructors initialize the object's
state.

Rules for Defining Constructor


The constructor name must be the same as the class name.
Constructors do not have a return type (not even void).
Constructors can be overloaded (multiple constructors with different parameters).

Method with Parameter


A method with parameters can accept values when it is called. For example:

void greet(String name) {


System.out.println("Hello, " + name);
}

Method with Return Type


A method with a return type returns a value to the caller. For example:

int add(int a, int b) {


return a + b;
}
Exception in Java
An exception in Java is an event that disrupts the normal flow of the program's instructions. It is
an object that represents an error or unexpected event that occurs during program execution.

Types of Exception
Checked Exceptions: Checked at compile-time (e.g., IOException, SQLException)
Unchecked Exceptions: Checked at runtime (e.g., NullPointerException,
ArithmeticException)

Errors: Serious issues not intended to be caught by applications (e.g., OutOfMemoryError)

If you need code examples or more details on any specific topic, let me know!

1. https://www.w3schools.com/java/java_intro.asp
2. https://www.w3schools.com/java/java_variables.asp
3. https://www.justacademy.co/blog-detail/why-is-java-known-as-platform-independent-language
4. https://www.tutorialspoint.com/java/java-features.htm
5. https://abhiandroid.com/java/local-variable-example.html
6. https://www.scaler.com/topics/global-variable-in-java/

You might also like