Oct 6, 2013

static method void return type reference parameter

static method with void return type and reference parameter

Java: static method void return type reference parameter in java-programming. Explaining working of a static method with void return type and reference parameter. Complete description of each term in static method void return type and reference parameter.

static methods are called without use of object i.e. methods which are declared as static can be called with corresponding class name. Methods can have either zero parameter or multiple parameters. Static methods can have arguments of both type i.e. primitive and reference. Like non-static methods, a static method's return type can be void or primitive or reference. When arguments passed with in the method are reference it means argument will be of class type or interface type or enum type or array type. A static method method whose return type is void then it means, this method will not return any value. Here is a program to explain the concept of Static method void return type reference parameter.


Example of static method void return type reference parameter:-

class SM
{
static void abc(SM y)
 {
   System.out.println("inside static method of abc");
 }
public static void main(String args[])
 {
  SM d=new SM();
 abc(d);
 }
}

In above program, method abc() is called without object because it is a static method and all static methods in java can be called with or without object if they are called in same class otherwise with corresponding class name.

Oct 5, 2013

Internal working of JVM(Java Virtual Machine)

Internal working of Java Virtual Machine(JVM) in java Programming

Java:Internal Working of JVM(Java Virtual Machine). Let us describe what is the internal working of Java Virtual Machine(JVM) in java-programming. I am describing here what happens internally in the JVM when a java-program is executed. Working of Java Virtual Machine is described below-

Working of Java Virtual Machine(JVM):-
  1. To load .class file from hard disk to RAM by the Class Loader Subsystem and stored into method memory area only once.
  2. To allocate the memory for all the static member of the specified class.
  3. If in specified class there is a static variable without initialized then JVM sets the default value of corresponding data type.
  4. If a class contains static blocks, then they executes in top to bottom order.
  5. Now control moves to the main method.
Above five steps defines the internal working of JVM(Java Virtual Machine) when a java-program is executed. 
.



Oct 2, 2013

static method void return type primitive parameter

static method with void return type with primitive parameter: Lets describe what is the mean of static method whose return type is primitive and it has primitive parameter. void return type i.e. it does not returns any type of value and primitive parameter means it has a parameter like int, char, float etc.... static method means it can be called with class name i.e. there is no need to create the object of the class for calling this method. A program for this tutorial is given below-

class Sm
{
 static void abc(int a,boolean b)
  {
    System.out.println("inside static method of abc of class Sm");
  }
public static void main(String args[])
  {
   int a=20;
   boolean c=true;
   Sm.abc(a,c);
  }
}

Explanation:
In this program we can also call abc() method directly without class name because within the same class we can call static method with or without class name.
For Example:
class Sm1
{
 static void abc1(int a,boolean b)
  {
    System.out.println("inside static method of abc of class Sm");
  }
public static void main(String args[])
  {
   int a=20;
   boolean c=true;
   abc1(a,c);
  }
}

Related posts:

Oct 1, 2013

static method void return type with zero parameter

Static method with Void Return type with zero parameter in java : This tutorial is provided to understand the mean of void return type with zero parameter.In java, there are three types of methods namely- 1) Void return type. 2) Primitive return type 3)reference return type. Void return type means a method which returns no value and zero parameter means no parameter is passed within the method. Let's demonstrate void return type method with zero parameter in java. Program for this tutorial is given below-


class Sm1
{
static void abc()
{
       System.out.println("inside static method of abc");
 }
 }
class  Test
{
public static void main(String[] args) 
{
Sm1.abc();
}
}

Explanation:
abc() is a staic method in this program i.e. it can be called without creating object of this class. So we called it with class name i.e. Sm1. abc() is not returning any type of value so its return type is declared as void and we have not used return statement in the method body area.