Question: Why do we need public static void main(String args) method in Java
Answer: We need
If the main() was not static, you would require an instance of the class in order to execute the method.
If this is the case, what would create the instance of the class? What if your class did not have a public constructor?
Question: What is the difference between an Interface and an Abstract class
Answer: In abstract class you can define as well as declare methods, the methods which are declared are to be marked as abstract.
In interface all we just declare methods and the definition is provided by the class which is implementing it
Question: Explain serialization
Answer: Serialization means storing a state of a java object by coverting it to byte stream
Question: What are the rules of serialization
1. Static fileds are not serialized because they are not part of any one particular object
2. Fileds from the base class are handled only if hose are serializable
3. Transient fileds are not serialized
Question: What is difference between error and exception
Answer: Error occurs at runtime and cannot be recovered, Outofmemory is one such example. Exceptions on the other hand are due conditions which the application encounters such as FileNotFound exception or IO exceptions
Question: What do you mean by object oreiented programming
Answer: In object oreinted programming the emphasis is more on data than on the procedure and the program is divided into objects.
The data fields are hidden and they cant be accessed by external functions.
The design approach is bottom up.
The functions operate on data that is tied together in data structure
Question: What are 4 pillars of object oreinted programming
It means hiding the details and only exposing the essentioal parts
Polymorphism means having many forms. In java you can see polymorphism when you have multiple methods with the same name
Inheritance means the child class inherits the non private properties of the parent class
It means data hiding. In java with encapsulate the data by making it private and even we want some other class to work on that data then the setter and getter methods are provided
Question: Difference between procedural and object oreinted language
Answer: In procedural programming the instructions are executed one after another and the data is exposed to the whole program
In OOPs programming the unit of program is an object which is nothing but combination of data and code and the data is not exposed outside the object
Question: What is the difference between constructor and method
Answer: Constructor will be automatically invoked when an object is created whereas method has to be called explicitly.
Question: What is the difference between parameters and arguments
Answer: While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments.
Question: What is reflection in java
Reflection allows Java code to discover information about the fields, methods and constructors of loaded classes and to dynamically invoke them
Question: What is a cloneable interface and how many methods does it contain
Answer: It is not having any method because it is a TAGGED or MARKER interface
Question: What's the difference between a queue and a stack
Answer: Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule
Question: Can you make an instance of abstract class
Answer: No you cannot create an instance of abstract class
Question: What are parsers
Answer: Parsers are used for processing XML documents. There are 2 types of parsers DOM parser and SAX Parser
Question: Difference between SAX and DOM parser
Answer: DOM parsers are Object based and SAX parsers are event based
DOM parsers creates Tree in the memory whereas SAX parser does not and hence it is faster than DOM
DOM parser are useful when we have to modify the XML, with SAX parser you cannot modify the xml, it is read only
Question: What is the difference between Java Bean and Java Class
Answer: Basically a Bean is a java class but it has getter and setter method and it does not have any logic in it, it is used for holding data.
On the other hand the Java class can have what a java bean has and also has some logic inside it
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles