Interview Questions and Answers - Order By Newest Q31. Can a lock be acquired on a class ?
Ans. Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   scheduling   threads   multi threading expert   rare Q32. Will Compiler creates a default no argument constructor if we specify only multi argument constructor ?
Ans. No, Compiler will create default constructor only if we don't specify any constructor. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   constructor   default constructor   yes-no expert   rare Try 1 Question(s) Test Q33. What is suspend() method used for ?
Ans. suspend() method is used to suspend the execution of a thread for a period of time. We can then restart the thread by using resume() method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading   operating system   synchronization basic   rare Usually asked only to fresh graduates. Q34. Difference between suspend() and stop() ?
Ans. Suspend method is used to suspend thread which can be restarted by using resume() method. stop() is used to stop the thread, it cannot be restarted again. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading   operating system   synchronization   suspend   stop basic   rare Q35. What is the difference between System.console.write and System.out.println ?
Ans. System.console() returns null if your application is not run in a terminal (though you can handle this in your application)System.console() provides methods for reading password without echoing charactersSystem.out and System.err use the default platform encoding, while the Console class output methods use the console encoding Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   system class   system.out.println   system.console.write   input output   java6 intermediate   rare Q36. Which load testing tools have you used ?
Ans. Rational Robot, JMeter, LoadRunner Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  testing   load testing   rational robot   jmeter   loadrunner   software tester basic   rare Q37. What data type Variable can be used in a switch statement ? Core Java
Ans. Variables used in a switch statement can only be a byte, short, int, or char ( and String with Java 7 and above ) Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   switch   variable   data type basic   rare Q38. What is the Locale class?
Ans. The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   locale   internationalization intermediate   rare Ans. PATH is the variable that holds the directories for the OS to look for executables. CLASSPATH is the variable that holds the directories for JVM to look for .class files ( Byte Code ). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   path   classpath   byte code   jvm   basic interview question Asked in 3 Companies intermediate   rare Rarely asked as default methods have been introduced with Java 8. Q40. Can we have a default method without a Body ? Core Java
Ans. No. Compiler will give error. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   default method   yes-no   rare Ans. A Closeable is an interface which is a source or destination of data that can be closed. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  closeable   interfaces intermediate   rare Q42. Name few Locale classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-locale-classes-and-interfaces.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   util   java.util   locale intermediate   rare Rarely asked as it was introduced with Java 8. Q43. Which keyword specify that a variable is effectively final ? a. final b. No Keyword c. Both of the above d. None of the above Core Java
Ans. No Keyword Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java 8   java8   final   effectively final   rare Q44. What is RI or Reference Implementation ?
Ans. RI or Reference Implementation is a sample implementation provided for the API's / Specs, usually by their developers. This is usually a part of API documentation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  reference implementation   help docs   helpdocs   api   apis   api specs   documentation   rare Q45. What is GregorianCalendar class ?
Ans. This class provides support for traditional Western calendars. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  GregorianCalendar   Calendar   util   core java   rare Q46. What is "Instance Initializer block" ?
Ans. Instance Initializer block is used to initialize the instance data member. It run each time when object of the class is created. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Instance Initializer block   rare Q47. Is it Necessary to send a POST request with the Payload or a body ? Web Service
Ans. No, we can also send an empty body with the POST Request. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Get Request   Rest   rare Q48. Can I hit the Rest Post Request through a browser address bar if it's not expecting any payload / body ? Rest
Ans. No, even if there is no payload, you can't hit the POST request by typing it into browser address bar. You will need a client that can make a POST Request. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Post Request   Rest  Calling Rest service through browser   rare Q49. 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 Usually asked with Questions related to Generics. Q50. 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 Q51. 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 Q52. 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 Q53. 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 Q54. 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 Ans. 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 Q56. 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 Q57. 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 Q58. 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 Q59. 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 Q60. 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