Java Interview Question And Answer | Java Interview Question And Answer For Fresher | Core Java Interview Question And Answare | Set 03

1.What is casting?
 Ans: Casting is process of convert the value of one type to another.

2.What are methods and how are they defined?
 Ans: Methods are functions that operate on instances of classes in which they are defined. By use of the method objects can communicate with each other and can call methods in other classes. Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method’s signature is a combination of the first three parts mentioned above

3.What is the difference between Assignment and Initialization?
 Ans: Assignment can be many times as desired whereas initialization can be only once.

4.What are Encapsulation, Inheritance and Polymorphism?
 Ans: Encapsulation: Encapsulation is a mechanism that associates code and data. It manipulates and keeps them safe from external interference and misuse.
     
        Inheritance: Inheritance is the process by which one object can acquire the properties of another object.
 
       Polymorphism: Polymorphism in Greak means many form. It allow a single name to be used for more than one related purpose which are technically different.

5.what is the difference between Abstract class and Interface?
 Ans: 1.In the interface all the methods must be declared abstract. In Abstract class at least one methode define as abstract.
        2.In interface no accessibility modifier are allowed which is possible in abstract class.

6.What is the difference between checked and Unchecked Exceptions in Java ?
 Ans: All predefined exceptions in Java are either a checked exception or an unchecked exception. Checked exceptions must be caught using try /java/ catch() block or we should throw the exception using throws clause. If you don't, compilation of program will fail. All exceptions in RuntimeExcetption and Error class are unchecked exception

7.What methods java providing for Thread communications ?
 Ans: Java provides three methods that threads can use to communicate with each other: wait, notify, and notifyAll.

8.What is the difference between notify and notify All methods ?
 Ans: A call to notify causes at most one thread waiting on the same object to be notified (i.e., the object that calls notify must be the same as the object that called wait). A call to notifyAll causes all threads waiting on the same object to be notified. If more than one thread is waiting on that object, there is no way to control which of them is notified by a call to notify (so it is often better to use notifyAll than notify).

9.What is serialization ?
 Ans: Serialization is the process of writing complete state of java object into output stream, that stream can be file or byte array or stream associated with TCP/IP socket.


10.What does the Serializable interface do ?
 Ans: Serializable is a tagging interface; it prescribes no methods. It serves to assign the Serializable data type to the tagged class and to identify the class as one which the developer has designed for persistence. ObjectOutputStream serializes only those objects which implement this interface.

Previous Next


:: Click the links below for similar type Questions and answers ::

0 comments:

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes