Rarely asked Interview Questions and Answers - 72 question(s) found - Order By Rating Q1. Explain Transitive equals contract. Core Java
Ans. The equals contract is said to be transitive if
obj1.equals(obj2); and obj2(.equals(obj3)
then obj1.equals(obj3) also returns true. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Transitive equals contract   rare Q2. Have you ever used java.util.Objects class ? Core Java
Ans. Yes, We are using requireNonNull method for validating if the object is null. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  objects  util methods   rare Q3. How many VTables are there for each class ? Core Java
Ans. There is one VTable for each class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  virtual table method  vtable  runtime polymorphism  object oriented programming (oops)  oops concepts   method overriding intermediate   rare Q4. How is the virtual method table implemented in Java? Core Java
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  virtual method table   method overriding  runtime polymorphism  object oriented programming (oops)  oops concepts expert   rare Q5. What is MVC in GUI components ? Design
Ans. The Model/View/Controller pattern, a strategy for dividing responsibility in a GUI component.
The model is the data for the component.
The view is the visual presentation of the component on the screen.
The controller is responsible for reacting to events by changing the model.
According to the MVC pattern, these responsibilities should be handled by different objects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  mvc  design pattern Asked in 1 Companies   rare Q6. What value you would like to see in an employee if you own a company ? General
Ans. The intent of this question is to see what values as a employee you have. So answer this cautiously as they will try to judge you on the basis of this answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies   rare Q7. What is the difference between TreeSet and TreeMap ? Core Java
Ans. TreeSet contains only values as elements whereas TreeMap contains Key value pairs. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  reeMap  TreeSet  Collections  sorted collection Asked in 1 Companies   rare Q8. How Bitly shortens the URL ? Web
This question was recently asked at 'Symantec'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  web application   url Asked in 1 Companies   rare Ans. A weak reference is a reference that gets removed on the next garbage collection cycle. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  weak reference  garbage collection Asked in 1 Companies   rare This question was recently asked at 'American International Group (AIG)'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  applet Asked in 1 Companies basic   rare Q11. How ConcurrentHashMap provides better performance compared to HashTable ? Core Java
Ans. ConcurrentHashMap uses multiple buckets to store Data and hence avoid read locks which facilitates better performance. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ashTabl expert   rare Q12. Why can we have a static inner class but not a static Top level class in Java ? Core Java
This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  static class  inner classes   nested classes Expert   rare Q13. How does making string as immutable helps with securing information ? How does String Pool pose a security threat ? Core Java
Ans. String is widely used as parameter for many java classes, e.g. network connection, opening files, etc. Making it mutable might possess threats due to interception by the other code segment or hacker over internet.
Once a String constant is created in Java , it stays in string constant pool until garbage collected and hence stays there much longer than what's needed. Any unauthorized access to string Pool pose a threat of exposing these values.
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Security  String pool   string immutable  immutability expert   rare Q14. How Marker interfaces works internally ? Core Java
This question was recently asked at 'GGK Technologies'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  marker interfaces  interfaces Asked in 1 Companies expert   rare Q15. What is Exception Wrapping ?
Ans. Exception wrapping is wrapping an exception object within another exception object and then throwing the outer exception. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exception handling  exception wrapping  exceptions intermediate   rare Q16. What is the difference between
File f = new File("homexyz.txt");
and
File f = File.createTempFile("xyz",".txt","home"); ? Core Java
Ans. First will not create physical file in storage whereas the second will. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  file handling  File.createTempFile  file handling intermediate   rare Q17. Which memory segment holds String Pool in Java ? Core Java
Ans. String Pool resides in runtime constant Pool which is a part of Heap memory segment. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  string pool  memory management Expert   rare Q18. How does Java handle integer overflows and underflows? Core Java
Ans. It uses those low order bytes of the result that can fit into the size of the type allowed by the operation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  integer  data types Asked in 1 Companies   rare Q19. Is there a way to know size of an object in Java ? Core Java
Ans. No, Java doesn't have a sizeOf operator. In C / C++ , its required to determine how much memory allocation is required which is not the case with Java. Java handles memory allocation and deallocation intrinsically. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sizeOf  size of object  sizeOf operator Asked in 1 Companies   rare Q20. Can we declare static variables as transient ? Core Java
Ans. It's weird that compiler doesn't complain if we declare transient with static variable because it makes no sense. At least a warning message saying "transient is useless in this situation" would have helped with code cleaning.
Static variables are never serialized and transient is an indication that the specified variable shouldn't be serialized so its kind of double enforcement not to serialize.
It could be that as it makes no different to the variable behavior and hence using both keywords with a variable are permitted. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  static  transient  serialization Asked in 1 Companies expert   rare Try 1 Question(s) TestAns. Everytime an object is serialized the java serialization mechanism automatically computes a hash value by passing the meta information for the class. This id is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  serialVersionUID  serialization Asked in 3 Companies expert   rare Q22. Can you write a "Hello World" program without using any ";" within it? Core Java
Ans. Yes, That is possible
class A {
public static void main(String args[]){
if(System.out.printf("Hello World")==null){}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Hello World  Hello world without ; Asked in 2 Companies   rare Q23. Write a Program to check if 2 strings are Anagrams ? Core Java
Ans. public void checkIfAnagram(String str1,String str2){
boolean anagram = true;
for(char c:str1.toCharArray()){
if(!str2.contains(String.valueOf(c))){
System.out.println("Strings are Anagrams");
anagram = false;
}
if(anagram == true){
System.out.println("Strings are not Anagrams");
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   check if 2 strings are Anagrams Asked in 30 Companies basic   frequent Q24. How can we catch an exception thrown by another thread ? Core Java
Ans. http://stackoverflow.com/a/6548203/2789764 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exception handling  exception expert   rare Q25. How can we find the memory usage of JVM from Java code? Core Java
Ans. Using Runtime object.
Runtime runtime = Runtime.getRuntime();
runtime.totalMemory();
runtime.freeMemory(); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jvm  memory management   rare Q26. Is ++ or -- operation thread safe in Java ? Core Java
Ans. No Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve     rare Q27. How can one determine if JVM is 32-bit or 64-bit from Java Program ? Core Java
Ans. There is a Java system property "sun.arch.data.model" that can tell if JVM is 32 bit of 64 bit
System.getProperty("sun.arch.data.model") can be used to get that property. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  jvm intermediate   rare Usually asked with Questions related to Generics. Q28. What are Type Erasures in Java ? Core Java
Ans. Type erasure applies to the use of generics. When generics are used, they're pre compiled into compile time checks and execution-time casts. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  type erasures  generics Asked in 2 Companies intermediate   rare Q29. Have you heard about the external table feature of Oracle ? Database
Ans. The external tables feature is a complement to existing SQL Loader functionality. It enables to access data in external sources as if it were in a table in the database. We have used it few times for replicating tables across different database systems. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  external table oracle Asked in 1 Companies   rare Q30. What happens to the Exception object after the exception handling is done ? Core Java
Ans. As with all other objects its garbage collected after its usage unless its rethrown. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  exceptions  exception handling   rare