Rarely asked Interview Questions and Answers - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Rarely asked Interview Questions and Answers - 72 question(s) found - Order By Newest

next 30
 Q1. What are the common uses of "this" keyword in java ?Core Java
Ans. "this" keyword is a reference to the current object and can be used for following -

1. Passing itself to another method.

2. Referring to the instance variable when local variable has the same name.

3. Calling another constructor in constructor chaining.

  Sample Code for this keyword

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   this   object reference   constructor chaining      intermediate        rare

Try 3 Question(s) Test


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


 Q3. Can we use both "this()" and "super()" in a constructor ?Core Java
Ans. No, because both this and super should be the first statement.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   oops  this   super   constructor     Asked in 1 Companies      intermediate        rare

Try 2 Question(s) Test


 Q4. What are concepts introduced with Java 5 ?Core Java
Ans. Generics , Enums , Autoboxing , Annotations and Static Import.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   java5   generics   enum   autoboxing   annotations   static import        rare

Try 1 Question(s) Test


 Q5. Can constructors be synchronized in Java ?Core Java
Ans. No. Java doesn't allow multi thread access to object constructors so synchronization is not even needed.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     synchronization   synchronize   constructor   java   multithreading   yes-no   advanced     Asked in 1 Companies      expert        rare


 Q6. 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) Test


 Q7. Does Constructor creates the object ?Core Java
Ans. New operator in Java creates objects. Constructor is the later step in object creation. Constructor's job is to initialize the members after the object has reserved memory for itself.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   constructor   object creation      intermediate        rare


 Q8. Will this code give error if i try to add two heterogeneous elements in the arraylist. ? and Why ?

List list1 = new ArrayList<>();
list1.add(5);
list1.add("5");
Ans. If we don't declare the list to be of specific type, it treats it as list of objects.

int 1 is auto boxed to Integer and "1" is String and hence both are objects.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   collections   arraylist   list   autoboxing   wrapper classes      expert        rare


 Q9. What are the Wrapper classes available for primitive types ?Core Java
Ans. boolean - java.lang.Boolean
byte - java.lang.Byte
char - java.lang.Character
double - java.lang.Double
float - java.lang.Float
int - java.lang.Integer
long - java.lang.Long
short - java.lang.Short
void - java.lang.Void

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   java5   data types   wrapper classes   adapter design pattern        rare


 Q10. Which String class does not override the equals() and hashCode() methods, inheriting them directly from class Object?Core Java
Ans. java.lang.StringBuffer.

  Sample Code for StringBuffer

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   object class   stringbuffer      expert        rare


 Q11. What is a ConcurrentHashMap ?Core Java
Ans. ConcurrentHashMap is a hashMap that allows concurrent modifications from multiple threads as there can be multiple locks on the same hashmap.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   collections   hashmap   map   concurrenthashmap   concurrenthashmap  concurrency   general electric   ge     Asked in 32 Companies        rare


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


 Q13. Can we serialize static variables ?Core Java
Ans. No. Only Object and its members are serialized. Static variables are shared variables and doesn't correspond to a specific object.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     serialization   java   oops   static   static variables     Asked in 1 Companies      intermediate        rare

Try 2 Question(s) Test


Usually asked only to fresh graduates.
 Q14. What is the difference between time slicing and preemptive scheduling ?Operating System
Ans. In preemptive scheduling, highest priority task continues execution till it enters a not running state or a higher priority task comes into existence. In time slicing, the task continues its execution for a predefined period of time and reenters the pool of ready tasks.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     operating system   scheduling   threads   multi threading        rare


 Q15. Are constructors inherited? Can a subclass call the parent's class constructor? When?Core Java
Ans. You cannot inherit a constructor. That is, you cannot create a instance of a subclass using a constructor of one of it's superclasses. One of the main reasons is because you probably don't want to override the superclasses constructor, which would be possible if they were inherited. By giving the developer the ability to override a superclasses constructor you would erode the encapsulation abilities of the language.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   oops   constructor   inheritence     Asked in 1 Companies      expert        rare

Try 1 Question(s) Test


 Q16. In which cases , moving methods to utility class could be useful ?Core Java
Ans. It could be worthy to move a method to util class if the method needs to be shared, doesn't require polymorphic behavior and need not be overridden in special cases.

Don't belong to one group through is-a relationship ( You can share through parent class method )

Don't implement a specific interface ( java 8 default methods )

Doesn't involve complex computing as you will be loosing the benefit of object state with just static method.

Doesn't require polymorphic behavior as static methods don't participate in runtime polymorphism.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     utility classes   util classes   static methods   application design        rare


 Q17.  What is the role of JSON.stringify ?Json
Ans.  JSON.stringify() turns an object into a JSON text and stores that JSON text in a string. 

So If we stringfy above notation , it will become

{"name":"xyz","gender":"male";"age":30}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     json   JSON.stringify      intermediate        rare


 Q18. What is URL?
Java EE
Ans. URL is Uniform Resource Locator which is representation of HTTP address.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     j2ee   http   internet   url      basic        rare


 Q19. Can I import same package/class twice? Will the JVM load the package twice at runtime?Core Java
Ans. One can import the same package or same class multiple times. Neither compiler nor JVM complains wil complain about it. And the JVM will internally load the class only once no matter how many times you import the same class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   import   jvm   advanced     Asked in 1 Companies      intermediate        rare


 Q20. Difference between boolean and Boolean ?Core Java
Ans. boolean is a primitive type whereas Boolean is a class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   oops   wrapper classes   boolean vs Boolean      basic        rare


 Q21. Can we declare an abstract method private ?
Ans. No Abstract methods can only be declared protected or public.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   abstract   oops   access specifier   private   yes-no      intermediate        rare


 Q22. What is Externalizable interface?Core Java
Ans. Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   serialization   externalizable interface     Asked in 2 Companies      intermediate        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. 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


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


 Q26. What is servlet Chaining ?Java EE
Ans. Multiple servlets serving the request in chain.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   web application   servlets     Asked in 1 Companies        rare


 Q27. Which interface does java.util.Hashtable implement?Core Java
Ans. Java.util.Map

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   collections   hashtable   map      basic        rare


 Q28. Difference between long.Class and Long.TYPE ?
Ans. They both represent the long primitive type. They are exactly the same.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   long.Class   long.TYPE   advanced      expert        rare


 Q29. What are transient variables in java?Core Java
Ans. Transient variables are variable that cannot be serialized.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   serialization   transient     Asked in 15 Companies      intermediate        rare


 Q30. Which memory segment loads the java code ?Core Java
Ans. Code segment.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     memory   java   memory management   code segment  code segment memory      expert        rare


next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: