Posts

Java Interview Questions (Part 1)

Java interview questions are provided here for the convenience of interviews. Fresher don't have any idea about the java question asked by interviewers in a java interview. Questions asked in java interview can be from any where. They can be from java development to java evolution. So here i am providing some important java interview questions for the java interviews. It will help them a lot in cracking a java interview. A list of java interview questions is given below- Question: Why Was Java Developed? Ans: Java was developed to provide the concept of platform independence by James Gosling and his team. Question: What is java? Ans: Java is the trademark of SUN MICRO SYSTEM. Note: There is no full form of java. Java is combination of 3 things: (1)Oops (2)Platform (3)Technology Question: What is program? Ans: Program is set of ...

Internals of Classes

Internals of Classes: Explaining internal mechanism of classes in java Internals of classes:   Classes in java are user defined data types.We can understand internal of classes with an example which is discussed below in this post.A java class is the container which stores members. Class members means methods,variables,blocks,constructor. Class binds multiple methods into a single unit. A class can have only four types of members i.e.  methods,variables,blocks,constructor.  As in real world, Human is a class,Vehicle is a class, Animal is a class same here in java there are classes having their objects. More specifically class is a concept. for ex- A class room which has its boundary, all things like fan,table,chair,computer are its member and the area in which these members exists is known as class. Program for a class in java- //defining class name in java programming class Java_prg { // main() method public static void main(String ...

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 v...

Internal working of JVM(Java Virtual Machine)

Image
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):- To load .class file from hard disk to RAM by the Class Loader Subsystem and stored into method memory area only once. To allocate the memory for all the static member of the specified class. If in specified class there is a static variable without initialized then JVM sets the default value of corresponding data type. If a class contains static blocks, then they executes in top to bottom order. 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.  .

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 {  sta...

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...

Job of new operator in java

What does new operator do? new operator in java is used for creating the object of the class. new operator instantiates the class and allocates memory to the object . As an object is instantiated all non-static member of the class are activated and ready to be used. It is the well known working of new operator, I want to tell you what happens in the memory when an object is created in the memory i.e. job of new operator or responsibilities of new operator in java programming. We will discuss step by step jobs of new operator. First i want to tell you how we create an object? class_name <reference variable> = new class_name(); Here,  <reference variable> is the variable of specified class and it stores the hashcode(address of object where it has been created) returned by the new operator. hashcode is in the form of hexadecimal code. Now we will discuss job of new operator. If .class file is not loaded  then to load the .class file from hard disk...