Interview Questions and Answers - Order By Newest Q271. How to display and set the Class path in Unix ?
Ans. To display the current CLASSPATH variable, use these commands in UNIX (Bourne shell): % echo $CLASSPATH To delete the current contents of the CLASSPATH variable, In UNIX: % unset CLASSPATH; export CLASSPATH To set the CLASSPATH variable, In UNIX: % CLASSPATH=/home/george/java/classes; export CLASSPATH Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  unix   unix commands   classpath Q272. Different ways of implementing Threads in Java ? Core Java
Ans. Threads in Java can be implement either by Extending Thread class or implementing runnable interface. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading Asked in 1 Companies basic   frequent Ans. A Method that cannot be overriden in the sub class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   final   final method   overriding   basic interview question basic   frequent Try 1 Question(s) TestVery Frequently asked.Favorite question in Walk in drive for many Indian service companies. Q274. What is a Final Class ?
Ans. A Class that cannot be sub classed. Sample Code for final class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   final   final class   java keyword   basic interview question Asked in 3 Companies basic   frequent Very frequently asked. Usually asked with questions related to String. Frequently asked at CTS / Cognizant Ans. Object that can't be changed after instantiation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   immutable  immutability Asked in 27 Companies basic   frequent Try 2 Question(s) Test Q276. Does Declaring an object "final" makes it immutable ? Core Java
Ans. Only declaring variables as final makes them immutable. Making objects final means that the object handler cannot be used to target some other object but the object is still mutable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   final   immutable  immutability   immutable  immutability object Q277. Can we override static methods ? Why ? Core Java
Ans. No. Static methods belong to the class and not the objects. They belong to the class and hence doesn't fit properly for the polymorphic behavior. A static method is not associated with any instance of a class so the concept of overriding for runtime polymorphism using static methods is not applicable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   static   static methods   java keywords   yes-no intermediate   frequent Q278. Can we reduce the visibility of the inherited or overridden method ? Core Java
Ans. No. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   access specifier   overriding   overridding   inheritence   yes-noAns. IndexOutofBoundException ,
NoClassDefFoundException ,
OutOfMemoryException ,
IllegalArgumentException,
NullPointerException,
IllegalStateException Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   exceptions   basic interview question basic   frequent Q280. How can we make sure that a code segment gets executed even in case of uncatched exceptions ?
Ans. By putting it within finally. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   exceptions   finally   uncatched exceptions basic   frequent Q281. What is "super" used for ?
Ans. Used to access members of the base class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   super   basic interview question Asked in 2 Companies basic   frequent Q282. What is "this" keyword used for ?
Ans. Used to represent an instance of the class in which it appears. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   this   basic interview question basic   frequent Q283. Difference between Serialization and Deserialization ? Core Java
Ans. Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   serialization   deserialization   serialization vs deserialization Asked in 2 Companies basic   frequent Try 1 Question(s) TestAns. An enum type is a special data type that enables for a variable to be a set of predefined constants Sample Code for enum Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java5   enum   basic interview question basic   frequent Try 2 Question(s) Test Q285. What are Wrapper Classes ? What are Primitive Wrapper Classes ? Core Java
Ans. A wrapper class is any class which "wraps" or "encapsulates" the functionality of another class or component. A Wrapper Class that wraps or encapsulates the primitive data type is called Primitive Wrapper Class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   wrapper classes   primitive wrapper classes Q286. What Design pattern Wrapper Classes implement ? Design
Ans. Adapter. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   wrapper classes   adapter design pattern   design patternAns. Enables the programmer to abbreviate the names of classes defined in a package. Sample Code for import Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   import   java keyword Q288. Different types of memory used by JVM ? Core Java
Ans. Class , Heap , Stack , Register , Native Method Stack. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   memory management   memory   advanced   architecture   technical architect Asked in 1 Companies intermediate   frequent Try 5 Question(s) Test Q289. What is a class loader ? What are the different class loaders used by JVM ? Core Java
Ans. Part of JVM which is used to load classes and interfaces.
Bootstrap , Extension and System are the class loaders used by JVM. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   class loaders  classloaders   jvm   java memory management   advanced Asked in 3 Companies Ans. By static import , we can access the static members of a class directly without prefixing it with the class name. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java5   static import   static   java keyword   static import Asked in 4 Companies basic   frequent Q291. Difference between Map and HashMap ? Core Java
Ans. Map is an interface where HashMap is the concrete class. Sample Code for map Sample Code for hashmap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashmap   map basic   frequent Ans. The properties class is a subclass of Hashtable that can be read from or written to a stream. Sample Code for Load Properties using Property Class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashtable   map   synchronization   synchronized Q293. Can we have multiple servlets in a web application and How can we do that ? Java EE
Ans. Yes by making entries in web.xml Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   servlets   servelets   web application   java   web.xml   yes-no   architecture Q294. How can we manage Error Messages in the web application ? Solution
Ans. Within message.properties file. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   web application   struts   spring Asked in 1 Companies Frequently asked to fresh graduates. Q295. Is JVM, a compiler or interpretor ?
Ans. Its an interpretor. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   compiler   interpretor basic   frequent Q296. Difference between Proxy and Adapter ? Design
Ans. Adapter object has a different input than the real subject whereas Proxy object has the same input as the real subject. Proxy object is such that it should be placed as it is in place of the real subject. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   proxy   adapter   proxy vs adapter expert Q297. Difference between Adapter and Facade ? Design
Ans. The Difference between these patterns in only the intent. Adapter is used because the objects in current form cannot communicate where as in Facade , though the objects can communicate , A Facade object is placed between the client and subject to simplify the interface. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   adapter   facade expert Q298. Example of Chain of Responsibility Design Pattern ?
Ans. Exception Handling Throw mechanism. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   chain of responsibility expert Q299. Example of Observer Design Pattern ?
Ans. Listeners. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   listeners   observer design pattern expert Q300. Which kind of memory is used for storing object member variables and function local variables ?
Ans. Local variables are stored in stack whereas object variables are stored in heap. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   memory management   stack memory   heap memory expert