Interview Questions and Answers - Order By Rating Q181. Tell something about Sleep method. Core Java
This question was recently asked at 'IBM'.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  Thread  sleep  multithreading Asked in 1 Companies Basic Q182. Which Java version supports Interface Default methods ? Core Java
Ans. Java 1.8 or Java 8 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  default methods   interface default methods   java 8  java 8 features Q183. Are Arrays a data structure or a collection class ? 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   Q184. Why Arrays are considered as data structures whereas ArrayList isn't ? 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   Q185. Difference between static and dynamic memory allocation ? 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   Q186. How is it possible to use concat on string objects in Java, based on the fact that string is immutable? Core Java
Ans. It's possible because internally java first reserves the memory for the new concatenated string and then copy that over. So after concatenation, there are 2 strings in memory, the original one and the concatenated one and then the reference is moved to the concatenated string. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q187. How do you implement 'state and behavior' of object in Java program? 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   Q188. Can we make array volatile in Java ? Core Java
Ans. Yes, you can make an array (both primitive and reference type array e.g. an int array and String array) volatile in Java but only changes to reference pointing to an array will be visible to all threads, not the whole array Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays  volatile Q189. Can we have 3 dimensional arrays in Java ? Core Java
Ans. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays Q190. Can we declare an array without assigning the size of an array? Core Java
Ans. No, It will throw compile time error saying "must provide either dimension expressions or an array initializer"
Alternatively we can provide array initializer like
String[] strArray = new String[]{"Buggy","Bread"};
which will initialize it to size 2 with values as "Buggy" and "Bread"
Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays  array initialization Q191. Write code to serialize and deserialize an array of strings ? 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   Q192. Difference between Arrays and ArrayList ? Core Java
Ans. Both Arrays and ArrayLists are used to store elements. Elements can be either primitives or objects in case of Arrays, but only objects can be stored in Arraylist. Array is a fixed length data structure while arraylist is variable length collection class. Once created, you cannot change the size of the arrays, but arraylists can dynamically resize itself when needed.Another notable difference between Arrays and Arrayslist is that arary is part of core java programming and array list is part of collection classes Sample Code for arrays
arraylist Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  array  arraylist  array vs arraylist Asked in 7 Companies basic   frequent Q193. What is the time and space complexity for different operations for arrays ? 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  arraysAns. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays  concurrency Asked in 1 Companies Q195. How can we check equality for Arrays in Java ? Core Java
Ans. You call the method java.util.Arrays.equals(Object[] a, Object[] a2)? Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays Q196. Are Arrays treated like primitives or like objects 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  arrays Q197. Where are arrays stored in memory - stack or heap ? 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  Ans. an array of different sizes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays  jagged arrays Q199. What is an anonymous array 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  anonymous arraysAns. It's an exception that is thrown when we attempt to add value of an incompatible type to an array.
For example -
Object[] strArray = new String[2];
strArray[0] = 5;
In this code, strArray reference of type Object has currently been assigned the String array but at line 2 we are trying to add an integer value. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  arrays   ArrayStoreException Q201. What is the difference between ArrayIndexOutOfBoundException and ArrayStoreException? 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  exception handling Q202. Can we use generics with arrays 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   Q203. Can we change the size of array once created ? Core Java
Ans. No. Arrays cannot resize dynamically. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  array  array size Basic 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  arrays Q205. Does Java generate .class file for interfaces ? Core Java
Ans. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  .class file  java byte code  interfaces Q206. Can we declare an Interface with abstract keyword ? Core Java
Ans. Yes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  abstract keyword Q207. Can we declare constructor inside an interface ? Why ? 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  interface   constructor Q208. Can we override a non-static method as static in Java ? Core Java
Ans. No, there is no method overriding with static methods. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve   Q209. Can you prevent overriding a method without using final modifier or without declaring it private ? 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   Q210. What is method hiding 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  method hiding