A constructor is a member function of a class that is used to create objects of that class. Q11) What is the difference between a constructor and a method?Īns. HashMap is unsynchronized and Hashtable is synchronized. HashMap does not guarantee that the order of the map will remain constant over time. (HashMap allows null values as key and value whereas Hashtable doesn't allow). The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. Q10) Difference between HashMap and HashTable?Īns. The map is Interface and Hashmap is the class that implements that. A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent. When an element is inserted into an ArrayList or a Vector, the object will need to expand its internal array if it runs out of room. Both the ArrayList and Vector hold onto their contents using an Array. In the Vector class each method is surrounded by a synchronized block and thus making Vector class thread-safe. ArrayList is not thread-safe whereas Vector is thread-safe. Q8) What is the difference between ArrayList and vector?Īns. Pass by Value means passing a copy of the value to be passed. Pass By Reference means passing the address itself rather than passing the value. String, Integer, Boolean, Character, Byte, Short, Long, Float, Double, BigDecimal, BigInteger Q7) What is pass by reference and pass by value?Īns. Immutable objects are automatically thread-safe since the state of the immutable objects can not be changed once they are created - All wrapper classes in Java. Since the state of the immutable objects can not be changed once they are created they are automatically synchronized/thread-safe. Immutable objects are objects whose state can not be changed once constructed. An immutable class is a class that once created, contents can not be changed. Q6) What is an immutable class? How to create an immutable class?Īns. The former is more advantageous, 'cause when you are going for multiple inheritances. The thread could be implemented by using a runnable interface or by inheriting from the Thread class. Q5) Explain the different ways of using thread?Īns. Do you want to master Advanced Java? Then enrol in "Advanced Java Training" This course will help you to master Advanced Java. This usually leads to significant errors. Without synchronization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating the same shared variable. With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Q4) Describe synchronization with respect to multithreading.Īns. Both the client side and server side have to provide mechanisms to make the data useful in any way. Socket-based communications allow only to send packets of raw data between applications. Sockets cause low network traffic unlike HTML forms and CGI scripts that generate and transfer whole web pages for each new request. Sockets are flexible and easy to implement for general communications. Q3) Advantages and disadvantages of Java Sockets. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. Q2) What is the purpose of garbage collection in Java, and when is it used?Īns. Java application on the other hand is a program that is being written in Java and being read by the Java virtual machine. When an application is compiled an object of that application is being made. Java object is an object that is provided by the execution of an application. Explain the difference between the abstract and final keywords?Īdvanced Java Interview Questions Q1) What are java objects and java applications?Īns.Do I need to import java.lang package any time? Why?.Can an application have multiple classes having the main method?.What if I do not provide the String array as the argument to the method?.What is synchronization and why is it important?.What is the difference between ArrayList and vector?.Explain the different ways of using thread?.Advantages and disadvantages of Java Sockets.What are java objects and java applications?.Most frequently asked Advanced Java Interview Questions Tekslate has collected the most frequently asked Java Advanced Interview Questions which are often asked in multiple interviews. Are you planning to attend an interview for a Java role but confused on how to crack that interview and also what would be the most probable Advanced Java Interview Questions that the interviewer may ask? Well, you have reached the right place.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |