• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 181 : - What is the difference between Serializalble and Externalizable interface?

Answer - 181 : - When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject() two methods to control more complex object serailization process. When you use Externalizable interface, you have a complete control over your class's serialization process.

Question - 182 : - Can you have virtual functions in Java?

Answer - 182 : - Yes, all functions in Java are virtual by default. This is actually a pseudo trick question because the word "virtual" is not part of the naming convention in Java (as it is in C++, C-sharp and VB.NET), so this would be a foreign concept for someone who has only coded in Java. Virtual functions or virtual methods are functions or methods that will be redefined in derived classes.

Question - 183 : - How to make an array copy from System?

Answer - 183 : - There is a method called arraycopy in the System class. You can do it: System.arraycopy(sourceArray, srcOffset, destinationArray, destOffset, numOfElements2Copy); When you use this method, the destinationArray will be filled with the elements of sourceArray at the length specified.

Question - 184 : - What is Collection API ?

Answer - 184 : - The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces. Example of classes: HashSet, HashMap, ArrayList, LinkedList, TreeSet and TreeMap. Example of interfaces: Collection, Set, List and Map.

Question - 185 : - Does garbage collection guarantee that a program will not run out of memory?

Answer - 185 : - Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Question - 186 : - What's the difference between constructors and other methods?

Answer - 186 : - Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

Question - 187 : - What is thread?

Answer - 187 : - A thread is an independent path of execution in a system.

Question - 188 : - The following statement prints true or false, why?

Answer - 188 : - byte[] a = { 1, 2, 3 };, byte[] b = (byte[]) a.clone(); System.out.println(a == b); The false will be printed out. Because the two arrays have distinctive memory addresses. Starting in Java 1.2, we can use java.util.Arrays.equals(a, b) to compare whether two arrays have the same contents.

Question - 189 : - Is sizeof a keyword?

Answer - 189 : - The sizeof operator is not a keyword.

Question - 190 : - What is synchronization and why is it important?

Answer - 190 : - With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners