Sunday 1 November 2015

METHOD OVERLOADING

Method overloading:->  When two or more methods in a class have the same method names with different arguments, it is said to be method overloading. Overloading does not block inheritance from the superclass. Overloaded methods must have different method signatures. But method name remains same.
                                                  Concentrate on these points
IN JAVA, Compiler checks method signature for duplicate methods or for method overloading. method signature consist of three things,
 1) Method Name   2) Number Of Arguments   3) Types of arguments.
NOTE-: If these three things are same for any two methods in a class, then compiler gives duplicate method error.
How to Check Compiler->Complier first check Method Name, then check further:
Ø  If Method Name is not equal then there will not be Method overloading.(as already said method name must be same.)
Ø  if Method Name is same then Complier will check Number Of Arguments, If methods differs in number of arguments, then it does not check types of argument. It treats as methods are overloaded.   
                           If number of arguments are same then compiler checks types of arguments. If types of arguments are also same, then compiler will give duplicate method error. If types of arguments are not same, then compiler will treat them as methods are overloaded. 

Yaad rhe -> In Method Overloading,  Methods may have same return types or different return types. It does not effect  on method overloading. And may have same access modifiers or different access modifiers. It also does not effect method overloading.  it is clear that compiler will check only method signature for method overloading or for duplicate methods. It does not check return types, access modifiers and static or non-static.
static/early binding polymorphism: overloading

public class TFSian_Class {
     
     
           public void read()                      // I
           {
                System.out.println("All Tfsian read");
           }
           public void read(int x)                 // II
           {
                System.out.println("Ranjeet reads more than " + x + " hours in a day");
           }
           public void read(String str)           // III
           {
                System.out.println("Reshma reads " + str);
           }
           public static void main(String args[])
           {
             TFSian_Class tfs = new TFSian_Class();

                 tfs.read();              // calls I
                 tfs.read(10);                  // calls II
                 tfs.read("SDLC");        // calls III
          }
     }

OutPut-> 
All Tfsian read
Ranjeet reads more than 10 hours in a day
Reshma read SDLC




In the above TFSian_Class  class, the same read() method is declared three times and each time takes different parameters – no parameter, int parameter and string parameter. Compiler can easily differentiate which method is to be called depending upon the number of parameters and their sequence of data types.
Return type in Overloading
See the following two method declarations.
public void read()
public int read()

The above two read() methods differ in their return type but not in parameters. Compiler cannot judge which is to be called depending on the return types; judges only on the parameter list. The above statements raise a compilation error. The return type may or may not be the same in method overloading.

                             

Method Overriding

Method Overriding
Method overriding :  When Subclass acquires the properties of Super class  through method then it is Method Overriding
                              Method Overriding in java is most useful features of java. Through inheritance we can reuse already existed code and through method overriding we can modify that reused code according to our requirements

Method Overriding Rules:-
  1. must be IS-A relationship (inheritance).
  2. method must have same name as in the super class
  3. method must have same parameter as in the super class.
  4. The return type of the overrided method must be compatible with super class method. If super class method has primitive data type as its return type, then overrided method must have same return type in sub class also. If super class method has derived or user defined data type as its return type, then return type of sub class method must be of same type or its sub class
  5. You cannot reduce the visibility of overloaded method in subclass.

Note- You cannot override static method in method overriding.because static method is related with class and method name with object.
dynamic/late binding polymorphism: overriding
public class Bank {
     
     
       
      int getRateOfInterest()
      {
      return 4;} 
      } 
       
      class PNB extends Bank{ 
      int getRateOfInterest(){return 9;} 
      } 
       
      class KENRA extends Bank{ 
      int getRateOfInterest(){return 6;} 
      } 
      class HDFC extends Bank{ 
      int getRateOfInterest(){return 9;} 
      } 
       
      class Test{ 
      public static void main(String args[]){ 
      PNB pnb=new PNB(); 
      KENRA kenra=new KENRA(); 
      HDFC hdfc=new HDFC(); 
      System.out.println("PNB Rate of Interest: "+pnb.getRateOfInterest()); 
      System.out.println("KENRA Rate of Interest: "+kenra.getRateOfInterest()); 
      System.out.println("HDFC Rate of Interest: "+hdfc.getRateOfInterest()); 
      } 
      }
OutPut-:
 PNB Rate of Interest: 9
KENRA Rate of Interest: 6
HDFC Rate of Interest: 9

.
.




Saturday 31 October 2015

MATRIX MULTIPLICATION



A- Rows in first Matrix
B- Columns for first  Matrix and Rows for Second Matrix
C- Columns for Second Matrix


package com.talent;

import java.util.Scanner;

public class MatrixMulti {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
  System.out.println("enter the rows for first matrix");
   int A=sc.nextInt();
 System.out.println("enter the no. for  columns  in first matirx / rows in second matrix ");
   int B=sc.nextInt();
   System.out.println("enter the columns in second matrix");
   int C=sc.nextInt();
 
 
   //now define all three matrix
       int [][]matrix1= new int[A][B];
       int [][]matrix2= new int[B][C];
       int [][]product= new int[A][C];
     
     
       System.out.println("enter the data for first elements");
     
       for(int i=0; i<A; i++)
       {
        for(int j=0; j<B; j++)
        {
        matrix1[i][j]=sc.nextInt();
        }
       
       }
 
     
      System.out.println("enter the data of second");
                for(int i=0; i<B; i++)
                {
                for(int j=0; j<C; j++)
               
                {
                matrix2[i][j]=sc.nextInt();
               
                }
               
                }
               
     
      System.out.println("first matirx is : ");
      for(int i=0; i<A; i++)
      {
     for(int j=0;j<B;j++)
     {
     System.out.print(matrix1[i][j]+"\t");
   
     }
     
     System.out.println();
      }
   System.out.println("second matirx is: ");
       for(int i=0; i<B; i++)
       {
        for(int j=0; j<C; j++)
       
        {
       System.out.print(matrix2[i][j]+"\t");
        }
        System.out.println();
       }
 
     
       System.out.println("PRODUCT IS : ");
       for(int i=0; i<A;i++)
       {
        for(int j=0; j<C; j++)
        {
       
        for(int k=0; k<B;k++)
        {
        product[i][j] += matrix1[i][k] * matrix2[k][j];
       
        }
        }
       
       }
 
   for(int i=0; i<A; i++)
   {
    for(int j=0; j<C; j++)
    {
    System.out.print(product[i][j]+"\t");
   
    }
    System.out.println();
   }
 
 

}

}

OUTPUT->enter the rows for first matrix
2
enter the no. for  columns  in first matirx / rows in second matrix
3
enter the columns in second matrix
2
enter the data for first elements
3
4
5
6
7
8
enter the data of second
3
4
5
6
7
8
first matirx is :
3 4 5
6 7 8
second matirx is:
3 4
5 6
7 8
PRODUCT IS :
64 76
109 130







Simple Matrix Programs

                                                                           Simple  Matrix

package com.talent;

import java.util.Scanner;

public class Matrix1 {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);
System.out.println("enter the no. of rows");
int row=sc.nextInt();

System.out.println("enter the no. of columns");
 int column=sc.nextInt();

 //now define 2D array to hold the matirx

 int[][]matrix=new int[row][column];

 System.out.println("enter the data");
           
 for(int i=0;i<row;i++)
 {
 for(int j=0; j<column; j++)
 {
 matrix[i][j]=sc.nextInt();

 }


 }

System.out.println("MATRIX IS :  ");

for(int i=0; i<row; i++)
{
for(int j=0; j<column; j++)
{
System.out.print(matrix[i][j]+"\t");
}
System.out.println();
}


}

}


OutPut->enter the no. of rows
3
enter the no. of columns
2
enter the data
4
5
6
7
8
9
MATRIX IS :
4 5
6 7
8 9






Friday 30 October 2015

Sorting String


                                                       Sorting String


package com.talent;

public class SortString {

public static void main(String[] args) {

   String []names={"Amit","neeraj","dhiraj","SHIPRA","azak","axdf"};
 
     sortStringBubble(names);
   
     for(int k=0;k<6;k++)
     {
   
    System.out.println(names[k]);
   
   
     }

}

private static void sortStringBubble(String[] x) {


boolean flag=true;

String temp;

while (flag) {


flag=false;

for (int j = 0; j < x.length-1; j++) {

if(x[j].compareToIgnoreCase(x[j+1])>0)

{
temp=x[j];
x[j]=x[j+1];
x[j+1]=temp;
flag=true;

}
}

}


}

}
OutPut->
Sorted String
Amit
axdf
azak
dhiraj
neeraj
SHIPRA

Find Character's Frequency


                                              Find Character's Frequency


package com.talent;

public class Find_Character_Frequency {


static int [] characterFrequency(String s)

  {

       s=s.toLowerCase();

    int frequency[]=new int[26];

   for (int i = 0,c=97; i < 26; i++,c++)

   {

   for (int j = 0; j < s.length(); j++)


     {

   char ch=s.charAt(j);

   

                   if(ch==c)
                  frequency[i]++;


} }
return frequency;
  }

 public static void main(String[] args) {



 String s="I am Java Developer";

 int frequency[]=characterFrequency(s);
 System.out.println("Albhabet \t Frequency");


 for (int i = 0,c=97; i <26; i++,c++) {
 if(frequency[i]!=0){
 char ch=(char)c;

 System.out.println(ch+"\t\t"+frequency[i]);


 }

}

}


}
OutPut->
Albhabet Frequency
a 3
d 1
e 3
i 1
j 1
l 1
m 1
o 1
p 1
r 1
v 2

Duplicate Elements in Java


                                                            




package com.talent;



public class Dublicate_Element {


public static void main(String[] args) {
         

        int A[]=new int[]{1,2,3,4,5,6,7,8,9}; //take element in array
int B[]=new int[A.length*2];      // here we double the size of array
     for (int i = 0,k=0; i < A.length; i++,k++)
           {
            B[k]=A[i];
            B[++k]=A[i];
          

  }
      for (int i = 0; i < B.length; i++) 
            {
   System.out.println(B[i]);
          }
}
}


OuTPuT->112233445566778899

How can increase and decrease the fonts in eclipse

                               How can increase and decrease the fonts in eclipse


Simple Steps for it--

Go to Install New Software

put it and download,


http://eclipse-fonts.googlecode.com/svn/trunk/FontsUpdate/

click ok and you will see two button on eclipse.




Monday 13 July 2015

Marker Interface in Java

Marker Interface in Java: what, why, uses?

What are Marker Interfaces in Java?

An empty interface having no methods or fields/constants is called a marker interface or a tag interface. This of course means if the interface is extending other interfaces (directly or indirectly) then the super interfaces must not have any inheritable member (method or field/constant) as otherwise the definition of the marker interface (an entirely empty interface) would not be met. Since members of any interface are by default ‘public’ so all members will be inheritable and hence we can say for an interface to be a marker interface, all of its direct or indirect super interfaces should also be marker. (Thanks marco for raising the point. I thought it was obvious, but mentioning all this explicitly would probably help our readers.)
There are few Java supplied marker interfaces like Cloneable, Serializable, etc. One can create their own marker interfaces the same way as they create any other interface in Java.
Purpose of having marker interfaces in Java i.e., why to have marker interfaces?
The main purpose to have marker interfaces is to create special types in those cases where the types themselves have no behavior particular to them. If there is no behavior then why to have an interface? Because the implementor of the class might only need to flag that it belongs to that particular type and everything else is handled/done by some other unit – either internal to Java (as in the case of Java supplied standard marker interfaces) or an app specific external unit.
Let’s understand this by two examples – one in which we will discuss the purpose of a standard Java interface (Cloneable) and then another user-created marker interface.
What purpose does the Cloneable interface serve?
When JVM sees a clone() method being invoked on an object, it first verifies if the underlying class has implemented the ‘Cloneable’ interface or not. If not, then it throws the exception CloneNotSupportedException. Assuming the underlying class has implemented the ‘Cloneable’ interface, JVM does some internal work (maybe by calling some method) to facilitate the cloning operation. Cloneable is a marker interface and having no behavior declared in it for the implementing class to define because the behavior is to be supported by JVM and not the implementing classes (maybe because it’s too tricky, generic, or low-level at the implementing class level). So, effectively marker interfaces kind of send out a signal to the corresponding external/internal entity (JVM in case of Cloneable) for them to arrange for the necessary functionality.
How does JVM support the ‘cloning’ functionality – probably by using a native method call as cloning mechanism involves some low-level tasks which are probably not possible with using a direct Java method. So, a possible ‘Object.clone’ implementation would be something like this:-
public Object clone() throws CloneNotSupportedException {

 if (this implements Cloneable)

 return nativeCloneImpl();

 else

 throw new CloneNotSupportedException();

}

Anyone wondered as to why and when do we get ‘CloneNotSupportedException’ exception at compile-time itself? Well… that’s no trick. If you see the signature of the ‘Object.clone()’ method carefully, you will see a throws clause associated with it. I’m sure how can you get rid of it: (i) by wrapping the clone-invocation code within appropriate try-catch (ii) throwing the CloneNotSupportedException from the calling method.
What purpose does a user-defined marker interface serve? It can well serve the same purpose as by any standard marker interface, but in that case the container (the module controlling the execution of the app) has to take the onus of making sure that whenever a class implements that interface it does the required work to support the underlying behavior – the way JVM does for Cloneable or any other standard marker interface for that matter.
Defining an user-defined marker interface in Java
Let’s define a user-defined marker interface. Let’s say there is an app suporting a medical store inventory and suppose you need a reporting showing the sale, revenue, profit, etc. of three types of medicines – allopathic, homeopathic, and ayurvedic separately. Now all you need is to define three marker interfaces and make your products (medicines) implement the corresponding ones.
public interface Allopathic{}
public interface Homeopathic{}
public interface Ayurvedic{}
In your reporting modules, you can probably get the segregation using something similar to below:-
for (Medicine medicine : allMedicines) {
if (medicine instanceof Allopathic) {
//... update stats accordingly
}
else if (medicine instanceof Homeopathic) {
//... update stats accordingly
}
else if (medicine instanceof Ayurvedic) {
//... update stats accordingly
}
else {
//... handle stats for general items
}
}
As you can see the medicines themselves don’t need to implement any specific behavior based on whether they are allopathic, homeopathic, or ayurvedic. All they need is to have a way of reflecting which category they belong to, which will in turn help the reporting modules to prepare the stats accordingly.
Now this can be done by having a flag as well… yeah, sure it can be. But, don’t you think tagging a class makes it more readable than having a flag indicating the same. You kind of make it an implementation-independent stuff for the consumers of your classes. If your class implements an interface, it becomes part of the class signature of the published API. Otherwise, you would probably handle the situation by having a public final field having the flag set up at the time of instantiation – final because you would not like others to change it. I guess going the marker interface way would probably make more sense in many such situations.
Another advantage of going via marker interface way is that at any point of time you can easily cast the objects of the implementing classes. Again it’s not that if you go via public final approach, you can’t do that. You can very well do, but casting might look a cleaner approach in many situations.
The bottom-line is there will hardly be any enforced need for a designer/developer to go via that way as there can be possible alternatives, but marker interfaces can surely be a preferred choice for some in some cases.

Thursday 9 July 2015

Core Java Interview Questions(VVI)




Core Java Interview Questions


1) what are static blocks and static initalizers in Java ?
2) How to call one constructor from the other constructor ?
3) What is method overriding in java ?
4) What is super keyword in java ?
5) Difference between method overloading and method overriding in java ?
6) Difference between abstract class and interface ?
7) Why java is platform independent?
8) What is method overloading in java ?
9) What is difference between c++ and Java ?
10) What is JIT compiler ?
11) What is bytecode in java ?
12) Difference between this() and super() in java ?
13) What is a class ?
14) What is an object ?
15) What is method in java ?
16) What is encapsulation ?
17) Why main() method is public, static and void in java ?
18) Explain about main() method in java ?
19) What is constructor in java ?
20) What is difference between length and length() method in java ?
21) What is ASCII Code?
22) What is Unicode ?
23) Difference between Character Constant and String Constant in java ?
24) What are constants and how to create constants in java?
25) Difference between ‘>>’ and ‘>>>’ operators in java?
Core java Interview questions on Coding Standards
26) Explain Java Coding Standards for classes or Java coding conventions for classes?
27) Explain Java Coding standards for interfaces?
28) Explain Java Coding standards for Methods?
29) Explain Java Coding Standards for variables ?
30) Explain Java Coding Standards for Constants?
31) Difference between overriding and overloading in java?
32) What is ‘IS-A ‘ relationship in java?
33) What is ‘HAS A’’ relationship in java?
34) Difference between ‘IS-A’ and ‘HAS-A’ relationship in java?
35) Explain about instanceof operator in java?
36) What does null mean in java?
37) Can we have multiple classes in single file ?
38) What all access modifiers are allowed for top class ?
39 ) What are packages in java?
40) Can we have more than one package statement in source file ?
41) Can we define package statement after import statement in java?
42) What are identifiers in java?
43) What are access modifiers in java?
44) What is the difference between access specifiers and access modifiers in java?
45) What access modifiers can be used for class ?
46) Explain what access modifiers can be used for methods?
47) Explain what access modifiers can be used for variables?
48) What is final access modifier in java?
49) Explain about abstract classes in java?
50) Can we create constructor in abstract class ?
51) What are abstract methods in java?
Java Exception Handling Interview questions
52) What is an exception in java?
53) State some situations where exceptions may arise in java?
54) What is Exception handling in java?
55) What is an error in Java?
56) What are advantages of Exception handling in java?
57) In how many ways we can do exception handling in java?
58) List out five keywords related to Exception handling ?
59) Explain try and catch keywords in java?
60) Can we have try block without catch block?
61) Can we have multiple catch block for a try block?
62) Explain importance of finally block in java?
63) Can we have any code between try and catch blocks?
64) Can we have any code between try and finally blocks?
65) Can we catch more than one exception in single catch block?
66) What are checked Exceptions?
67) What are unchecked exceptions in java?
68) Explain differences between checked and Unchecked exceptions in java?
69) What is default Exception handling in java?
70) Explain throw keyword in java?
71) Can we write any code after throw statement?
72) Explain importance of throws keyword in java?
73) Explain the importance of finally over return statement?
74) Explain a situation where finally block will not be executed?
75) Can we use catch statement for checked exceptions?
76) What are user defined exceptions?
77) Can we rethrow the same exception from catch handler?
78) Can we nested try statements in java?`
79) Explain the importance of throwable class and its methods?
80) Explain when ClassNotFoundException will be raised ?
81) Explain when NoClassDefFoundError will be raised ?
Java Interview questions on threads
83) What is process ?
84) What is thread in java?
85) Difference between process and thread?
86) What is multitasking ?
87) What are different types of multitasking?
88) What are the benefits of multithreaded programming?
89) Explain thread in java?
90) List Java API that supports threads?
91) Explain about main thread in java?
92) In how many ways we can create threads in java?
93) Explain creating threads by implementing Runnable class?
94) Explain creating threads by extending Thread class ?
95) Which is the best approach for creating thread ?
96) Explain the importance of thread scheduler in java?
97) Explain the life cycle of thread?
98) Can we restart a dead thread in java?
99) Can one thread block the other thread?
100) Can we restart a thread already started in java?
101) What happens if we don’t override run method ?
102) Can we overload run() method in java?
105) What is a lock or purpose of locks in java?
106) In how many ways we can do synchronization in java?
107) What are synchronized methods ?
108) When do we use synchronized methods in java?
109) When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?
110) When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?
111) What are synchronized blocks in java?
112) When do we use synchronized blocks and advantages of using synchronized blocks?
113) What is class level lock ?
114) Can we synchronize static methods in java?
115) Can we use synchronized block for primitives?
116) What are thread priorities and importance of thread priorities in java?
117) Explain different types of thread priorities ?
118) How to change the priority of thread or how to set priority of thread?
119) If two threads have same priority which thread will be executed first ?
120) What all methods are used to prevent thread execution ?
121) Explain yield() method in thread class ?
122) Is it possible for yielded thread to get chance for its execution again ?
123) Explain the importance of join() method in thread class?
124) Explain purpose of sleep() method in java?
125) Assume a thread has lock on it, calling sleep() method on that thread will release the lock?
126) Can sleep() method causes another thread to sleep?
127) Explain about interrupt() method of thread class ?
128) Explain about interthread communication and how it takes place in java?
129) Explain wait(), notify() and notifyAll() methods of object class ?
130) Explain why wait() , notify() and notifyAll() methods are in Object class rather than in thread class?
131) Explain IllegalMonitorStateException and when it will be thrown?
132) when wait(), notify(), notifyAll() methods are called does it releases the lock or holds the acquired lock?
133) Explain which of the following methods releases the lock when yield(), join(),sleep(),wait(),notify(), notifyAll() methods are executed?
134) What are thread groups?
135) What are thread local variables ?
136) What are daemon threads in java?
137) How to make a non daemon thread as daemon?
138) Can we make main() thread as daemon?
Interview questions on Nested classses and inner classes
139) What are nested classes in java?
140) What are inner classes or non static nested classes in java?
141) Why to use nested classes in java?
142) Explain about static nested classes in java?
143) How to instantiate static nested classes in java?
144) Explain about method local inner classes or local inner classes in java?
145) Explain about features of local inner class?
146) Explain about anonymous inner classes in java?
147) Explain restrictions for using anonymous inner classes?
148) Is this valid in java ? can we instantiate interface in java?
149) Explain about member inner classes?
150) How to instantiate member inner class?
151) How to do encapsulation in java?
152) What are reference variables in java ?
153) Will the compiler creates a default constructor if I have a parameterized constructor in the class?
154) Can we have a method name same as class name in java?
155) Can we override constructors in java?
156) Can Static methods access instance variables in java?
157) How do we access static members in java?
158) Can we override static methods in java?
159) Difference between object and reference?
160 ) Objects or references which of them gets garbage collected?
161) How many times finalize method will be invoked ? who invokes finalize() method in java?
162) Can we able to pass objects as an arguments in java?
163) Explain wrapper classes in java?
164) Explain different types of wrapper classes in java?
165) Explain about transient variables in java?
166) Can we serialize static variables in java?
167) What is type conversion in java?
168) Explain about Automatic type conversion in java?
169) Explain about narrowing conversion in java?
170) Explain the importance of import keyword in java?
171) Explain naming conventions for packages ?
172) What is classpath ?
173) What is jar ?
174) What is the scope or life time of instance variables ?
175) Explain the scope or life time of class variables or static variables?
176) Explain scope or life time of local variables in java?
177) Explain about static imports in java?
178) Can we define static methods inside interface?
179) Define interface in java?
180) What is the purpose of interface?
181) Explain features of interfaces in java?
182) Explain enumeration in java?
183) Explain restrictions on using enum?
184) Explain about field hiding in java?
185) Explain about Varargs in java?
186) Explain where variables are created in memory?
187) Can we use Switch statement with Strings?
188) In java how do we copy objects?

Oops concepts interview questions

189) Explain about procedural programming language or structured programming language and its features?
190) Explain about object oriented programming and its features?
191) List out benefits of object oriented programming language?
192) Differences between traditional programming language and object oriented programming language?
193) Explain oops concepts in detail?
194) Explain what is encapsulation?
195) What is inheritance ?
196) Explain importance of inheritance in java?
197) What is polymorphism in java?

Collection Framework interview questions


198) What is collections framework ?
199) What is collection ?
200) Difference between collection, Collection and Collections in java?
201) Explain about Collection interface in java ?
202) List the interfaces which extends collection interface ?
203) Explain List interface ?
204) Explain methods specific to List interface ?
205) List implementations of List Interface ?
206) Explain about ArrayList ?
207) Difference between Array and ArrayList ?
208) What is vector?
209) Difference between arraylist and vector ?
210) Define Linked List and its features with signature ?
211) Define Iterator and methods in Iterator?
212) In which order the Iterator iterates over collection?
212) Explain ListIterator and methods in ListIterator?
213) Explain about Sets ?
214) Implementations of Set interface ?
215) Explain HashSet and its features ?
216) Explain Tree Set and its features?
217) When do we use HashSet over TreeSet?
218) What is Linked HashSet and its features?
219) Explain about Map interface in java?
220) What is linked hashmap and its features?
221) What is SortedMap interface?
222) What is Hashtable and explain features of Hashtable?
223) Difference between HashMap and Hashtable?
224) Difference between arraylist and linkedlist?
225) Difference between Comparator and Comparable in java?
226) What is concurrent hashmap and its features ?
227) Difference between Concurrent HashMap and Hashtable and collections.synchronizedHashMap?
228) Explain copyOnWriteArrayList and when do we use copyOnWriteArrayList?
229) Explain about fail fast iterators in java?
230) Explain about fail safe iterators in java?
Core java Serialization interview questions
231) What is serialization in java?
232) What is the main purpose of serialization in java?
233) What are alternatives to java serialization?
234) Explain about serializable interface in java?
235) How to make object serializable in java?
236) What is serial version UID and its importance in java?
237) What happens if we don’t define serial version UID ?
238) Can we serialize static variables in java?
239) When we serialize an object does the serialization mechanism saves its references too?
240) If we don’t want some of the fields not to serialize How to do that?
241) Explain importance of object class in java?
242) Explain purpose of object class or why object class is super class for all java classes?
243) Explain Object class methods?
244) List methods which can be overrided from Object class?
245) Explain purpose of toString() method in java?
Core Java Interview Questions on Strings
246) Explain Strings in java?
247) Difference between Strings and Character Arrays in java?
248) Explain importance of String class in java?
249) In how many ways we can create Strings in java?
250) Explain how to create Strings using String literal and advantages of creating Strings using String literal?


Core Java Interview Questions on Class Loaders
251) What are classloaders and different types of class loaders in java?
252) What is BootStrap class loader and how does it works?
253) What is Extensions class loader and how does it works?
254) What is application class loader and how does it works?

Java Interview Questions on Garabage Collection
255) What is garbage Collection in java?
256)When an object becomes eligible for garbage collection?
257) Who performs garbage collection?
258) When does garbage collector run?
259) Which algorithm garbage collector uses to perform garbage collection?
260) List out different garbage collection algorithms?
261) Can we force JVM for garbage collection?
262) How to request jvm to perform garbage collection operation?
263) Explain the purpose of finalize method in relation to Garbage collection?
264) How many times finalize method is called on an Object?
265) Once an object is garbage collected can it become reachable again?
266) How to write a code that makes an object eligible for garbage collection?

Java interview questions on main method
267) Explain purpose of main method() in java?
268) List out different valid main method declarations ?
269) Who calls main() method?
270) Is it mandatory to define main method() in a class?
271) If we don’t define a main method and execute a class do we get any error?
272) Can a developer call main method explicitly ?
273) Can we call main method from same class ?
274) Does JVM calls user defined methods with same signature as main with name change?
275) Can we have a overloaded main method in a class? If we have overloaded method which main method does jvm call?
276) Can we have multiple classes in a java file with each class having main method?

Interview Questions on Operators in java
277) Explain operators and different types of operators in java?
278) Explain different categories of operators in java?
279)Explain arithmetic operators and different arithmetic operators in java?
280)Explain % operator in java with example?
281) Explain Relational Operators with example?
282) Explain unary arithmetic operator with example?
283) Explain difference between preincrement and post increment operators in java?
284) Explain difference between predecrement and post decrement operators in java?
285) Explain complement operator(!) in java with example?
286) Explain Bitwise complement operator(~) in java with example?
287) Explain conditional operator and different conditional operators in java?
288) Explain ternary operator with example?
289) Explain short circuit operator (and && or ||) operator in java?
290)Explain rules for java source code files?
291) Explain different styles of comments in java?
292) Can we nest comments in java?
293) List out different primitive types in java?
294) To what values primitives in java get automatically initialized?
295) To which values Strings get automatically initialized to?
296) Which package gets automatically imported by default?
297) Which non Unicode letters can be used as first letters for naming identifiers?
298) Which characters can be used for naming identifiers as second letter but not as first letter?
299) Is null a keyword in java?