Java Programing laungage

Core Java Tutorial

Introduction of Core Java

How To Install JDk and Set of Path

Syntax of java Program

Difference between Java and C/C++

Advantage and Disadvantage of Java

What is Java

Why Java is not Pure Object Oriented Language

Java has Following Features/Characteristics

Limitation of Java Language and Java Internet

Common Misconception about Java

Simple Program of Java

Integrated Development Environment in java

Compile and Run Java Program

Applet and Comments in Java

Tokens in Java

Keywords in Java

Identifier and Variables in Java


Data Type in Java

Assignments and Initialization in Java

Operators in Java

Rule of Precedence in Java

Operator on Integer and Separators in Java Programming

Java Control Flow of Statements

If and If-else Selection Statement

Nested If-else and If-else-If Selection Statement

switch case and conditional operator Selection Statement

for and while Loop

do..while and for each Loop

break and labeled break statement

continue and labeled continue statement

return Statement and exit() Method

Escape Sequence for Special Characters and Unicode Code

Constants and Block or Scope

Statement in Java

Conversions between Numeric Types in Java

Import Statement in Java

User Input in Java using Scanner Class

User Input in Java using Console Class

Array in Java

One Dimensional Array

Two Dimensional Array

Two Dimensional Array Program

Command Line Argument in Java

String args Types in Java

Uneven/Jagged array in java

Math Class Function and Constant

Math Class all Function used in a program

Enumerated Types in Java

Object Oriented Programming v/s Procedural Programming

Object Oriented Programming Concepts in Java

Introduction to Class,Object and Method in Java

Class Declaration in Java

Class & Objects in java

Encapsulation in Java

Modifiers/Visibility for a Class or Interrface or member of a Class

Polymorphism in Java

Runtime polymorphism (dynamic binding or method overriding)

Types of Member Methods in Java
Previous Home Next

There are two types of member methods in java

  1. Instance Member Methods/Non-Static member Methods.
  2. Static Member Methods.

Instance Member Methods

  1. Instance method is defined in a class which is only accessable through the Object of the class are called Instance method.
  2. These methods can only be called through objects.
  3. Non-static member are declared without the static keyword.
  4. If we call a instance method inside a static method of same class then also we have to use object name.
  5. When an object calls a method then it is called as message passing and this is feature of oops.
  6. When an object calls a method then the referrence of the object is automatically passed as an argument to the method and this reference will be received by this keyword inside the class.

Syntax of instance method

return-type funcName(paramList)
     // Body of this method

return-type is the type of answer that the method produces.

Syntax to call instance method


objRef is an object reference variable and funcName is the name of the method. args are an optional arguments.

Example :

class Instance
	int l = 9; //non-static 
	double d = 12.2;//non static 
	void sample() //non-static method 
public static void main(String args[]) 
	Instance i = new Instance();//instance creation 
	System.out.println("program ends...."); 

output :

Program end....

Static Member Methods

  1. These methods can be called through class name or through object name.
  2. Static methods can access ony static member. Static method can be called directly (without object or class name) from a static method of same class.
  3. This keyword will not work inside a static method because this contains the reference of the calling object but static method is generally called through class name and even if static method is called through object then also the reference of calling object will not passed in the method.
  4. Super keyword will also not work.
  5. Instance member variables can not work directly inside a static method but using object we can access in instance member also.
  6. static method can use only static variables.

Example1 :

class A
	int x; // instance member variables
	static void m()
public static void main(String args[])

output :

Error - Static method can not  access instance variable

Example2 :

class A
	int x;  //instance variable
	static void m()
		A a1=new A();
class StaticMethod
	public static void main(String args[])

Output :


Example3 :

class Math
            static int sum(int a, int b)
            static float avg(int a, int b)

  class mathMathod
            public static void main(String args[])
                    Math m=new Math();

output :

Previous Home Next