Static Method

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

 OOPS JAVA

features of Java programming language :


1. Object oriented -> java can easily extended since it is based on the
object model
2. Platform independent -> Unlike many other programming languages
including C and C++, when Java is compiled, it is not compiled into platform
specific machine, rather into platform-independent byte code. This byte code
is distributed over the web and interpreted by the Virtual Machine (JVM) on
whichever platform it is being run on.
3. Simple
Java is designed to be easy to learn. If you understand the basic concept of
OOP Java, it would be easy to master.
4. Secure
With Java's secure feature it enables to develop virus- free, tamper-
free systems. Authentication techniques are based on public-key encryption.
5. Architecture-neutral
Java compiler generates an architecture-neutral object file format, which makes
the compiled code executable on many processors, with the presence of Java
runtime system.
6. Portable: Being architecture-neutral and having no implementation
dependent aspects of the specification makes Java portable. The
compiler in Java is written in ANSI C with a clean portability
boundary, which is a POSIX subset

7. Robust :
Java makes an effort to eliminate error-prone situations by emphasizing
mainly on compile time error checking and runtime checking.

8. Multithreaded
With Java's multithreaded feature it is possible to write programs that can
perform many tasks simultaneously. This design feature allows the developers to
construct interactive applications that can run smoothly.

9. Interpreted
Java byte code is translated on the fly to native machine instructions and is not
stored anywhere. The development process is more rapid and analytical since the
linking is an incremental and light-weight process.
10. High Performance
With the use of Just-In-Time compilers, Java enables high performance.
11. Distributed
Java is designed for the distributed environment of the internet.
12. Dynamic
Java is considered to be more dynamic than C or C++ since it is designed to
adapt to an evolving environment. Java programs can carry an extensive amount
of run-time information that can be used to verify and resolve accesses to objects
at run-time.
 JVM
JVM or Java Virtual Machine is a specification to provide the runtime
environment on which a bytecode can be executed. JVMs are prepared platform
specific and are available for almost all the hardware and machine.
Features of JVM −
 It provides class loader to load a class.
 It provides bytecode verifier to verify the legality of the bytecode.
 It provides runtime.
 It executes the bytecode

 BYTECODE
 When an application is written in Java, the Java compiler ( cmd-
javac )converts the source code ( File.java )to bytecode, outputting the
bytecode to a CLASS file (File.class ). The CLASS file is then read and
processed by a Java virtual machine (JVM) running on a target system.

BASIC PROGRAM:
public class Myfirst {
Public static void main (String args[]) {
System.out.print(“ MIT-WPU”);
}
}

Public-> for access it to everyone


Static -> for using class without creating object
Void main -> name of the function
String args[]-> argument to method an array of the string
System.out.print -> for printing

 CLASSES AND OBJECTS


A class is a blueprint for the object. Before we create an object, we first need to
define the class.
Object is a collection of method function and variables .
Each object made from that class can have its own values for the instance
variable of that class.
Things that object can do is called methods .
Things that an object known about itself is called instance variable

Program of class and object


Class Demo { //this is class
Void display() {
System.out.print(“class demo”);
}
Public static void main(String args[]) {
Demo d = new Demo(); // this is object of class that
d.display(); calling the method of cls
}
}

 STATIC METHOD :

 We can invoke static method directly using the class name


 Static method are also called cause static method belongs to class
rather than the object of class
STATIC VARIABLE :
STSTIC BLOCK

 STATIC KEYWORD :
 If we want to access class members without creating an instance of the class
we need to declared the class member static
 Whatever is declared in static class it means all function are become static
only.
 Any static member can be used/access before any object of its class are
created and without references to any object.
 FINAL KEYWORD:
 It is non access modifier used for classes attributes and method which
makes them non changeable
 Once any entity (variable, method or class) is declared final, it can be
assigned only once. That is,
a. the final variable cannot be reinitialized with another value
b. the final method cannot be overridden
c. the final class cannot be extended
 the Final class cannot be inherited by another class
 Final Method cannot be overridden by the Chid class
 Final variable value cannot change
 Inheritance :
 The inheritance allows subclasses to inherits all the variables and methods
of their parent classes.
 Inheritance may take different forms .
1. Single inheritance (only one super class)
2. Multi inheritance ( several super class)
3. Hierarchical inheritance (one superclass ,many sub classes)
4. Multilevel inheritance (Derived from a derived class)
 The keyword extends signifies that the properties of the superclass name
are extended to the subclass name
 The sub class contains own variables and methods as well as super class.
 This keyword :
 It will be reference of same class
 this keyword is used to refer to the current object inside a method or a
constructor.
 Super keyword:
 The super keyword in Java is used in subclasses to access superclass
members (attributes, constructors and methods).

 Abstract class:
 The abstract class in Java cannot be instantiated (we cannot create objects
of abstract classes). We use the abstract keyword to declare an abstract
class.

You might also like