Interview Questions and Answers - Order By Newest Q1031. Can you name few Java packages which you frequently used ? Core Java
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   Asked in 1 Companies Q1032. How does encoding affect using Reader / writer classes or Stream classes in Java ? Core Java
Ans. Which group of bytes represent which character is defined by character encoding. So when reading character by character from a stream of bytes using Reader, specifying character encoding becomes significant as the same group of bytes can represent different character in different character encoding(Eg UTF-8 and UTF-16 etc.) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  File io  File handling  Reader  Writer  Stream Asked in 1 Companies Q1033. How executor service is better than using primitive Threading mechanism using Thread class or runnable Interface ? Core Java
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  multithreading  threads Asked in 1 Companies Q1034. 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 Q1035. Which of the following is insertion heavy - HashSet or TreeSet ? Core Java
Ans. TreeSet as it needs elements in a particular order Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1036. Write a Program to print a pattern ? Core Java
This question was recently asked at 'Real come info'.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   Asked in 1 Companies basic Q1037. Have you used Java 8 Lambda expressions ? Core Java
This question was recently asked at 'One Click Retail'.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  java 8  lambda expressions Asked in 1 Companies   frequent Q1038. How to calculate string length without using inbuilt function Core Java
This question was recently asked at 'Softenger'.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  code  coding  design  string length Asked in 1 Companies basic Q1039. What is the difference between abstraction and abstract class ? Core Java
Ans. Abstract class is one of the facility for achieving abstraction in Java. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1040. Write code to print a Pyramid pattern ? Core Java
Ans. public static void printTriagle(int n)
{
// outer loop to handle number of rows
// n in this case
for (int i=0; i1; j--)
{
// printing spaces
System.out.print(" ");
}
// inner loop to handle number of columns
// values changing acc. to outer loop
for (int j=0; j<=i; j )
{
// printing stars
System.out.print("* ");
}
// ending line after each row
System.out.println();
}
}
// Driver Function
public static void main(String args[])
{
int n = 5;
printTriagle(n);
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Ans. Generally used to indicate termination Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Asked in 1 Companies Q1042. How to sort objects based on one of the field ? Core Java
Ans. Using comparable and comparator and sorted collections like TreeSet or TreeMap.
or
use stream api from java 8 onwards which internally refers to comparable and comparator through lambda expressions Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  sort  sorting  comprator  comparable  treeset  treemap  sorting collections Asked in 1 Companies Basic   frequent Q1043. Can we have interface as a replacement for utility class ? Core Java
Ans. Yes, With Java 8 we can use Interfaces as collection of utility methods through the use of default methods. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java 8  interfaces  utility class   utility classes Q1044. What are custom annotations and How can we create one ? 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  annotations  custom annotations basic Q1045. What is the difference between scope and access modifiers ? Core Java
Ans. Scope modifiers changes the scope of a particular element or a method. For ex - static changes the scope of that of class and not of object.
Access modifiers changes the access priviledges of a particular element or a method. For ex - private , public etc. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  scope modifiers   access modifiers   scope vs access modifiers Asked in 2 Companies basic This question was recently asked at 'Avis'.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  final class   final keyword Asked in 1 Companies basic Q1047. Which memory segment is cleaned by Garbage Collection - stack or heap ? Core Java
Ans. Heap as objects are stored ink heap. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  memory management   stack  heap  garbage collection Q1048. Do we have references for the objects that are eligible for garbage collection ? 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   Q1049. Are final methods faster than regular instance methods ? Core Java
Ans. Yes. As they cannot be overridden , there is no use of virtual table concept which is used for dynamic binding resolution. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  final methods   final keyword expert Q1050. What is virtual table with respect to method overriding 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  vtable  virtual method table   method overriding  runtime polymorphism  object oriented programming (oops)  oops concepts Q1051. 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 Q1052. 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 Q1053. 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 Q1054. Why do we use getbytes in Java? Core Java
Ans. It is used to convert String into an array of bytes.
byte[] getBytes() - converts String into a byte array.
byte[] getBytes(Charset charset) - converts String to byte array, based on charset encoding. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1055. Can Java be run on hardware with just the JVM and no OS ? 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   Q1056. Which java feature is used to convert primitive type to reference type ? Core Java
Ans. AutoBoxing Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q1057. What is a reflexive equals contract ? Core Java
Ans. An equal contract is said to be reflexive is equality between 2 objects always returns to be true.
For example -
Object o1;
Object o2;
o1.equals(o2); // returns true
o2.equals(o1); //returns true Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  reflexive equals contract Q1058. 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 Q1059. How will you enable or disable assertion for a package during runtime ? 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   Q1060. Which java version supports assertion ? 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