Java interview question answer



1. What is java?
Java is a OOP based computer programming language. 
2. Explain, what is the difference between private, protected, and public in java?
These java keywords are for following privileges to component such as variables and methods.
Public: All classes can be access
Private: Can be access only the class to which belongs
Protected: Can be access to the class to which they belongs and any subclasses.
3. What are access specifiers in java?
Access specifiers are keywords that determine the type of access to the member of a class. 
There are four types of specifiers in java (a) Public, (b) Private, (c) Protected, and (d) Defaults.
4. What's the difference between normal methods and constructors?
Constructors cannot return a value and must have the same name as the class. Constructors are only called once while normal methods could be called many times and it can return a value or can be void (it is your choice).
 5. It is possible to call one constructor from another if there are multiple constructors in a class?
Yes. It is possible using this() to call a constructor from another constructor.
6. How to usage of Java packages?
It is a technique to organize files when a project consists of many modules. Packages access level also allows you to protect data from being used by the non-authorized classes. . Java packages also helps resolve naming conflicts when different packages have classes with the same names.
7. What is the difference between OOP and procedural programming?-
1) In procedural programming, program code executes line by line. In OOP program cannot execute line by line.  2) In procedural program, data is can be used in the whole program whereas in a object oriented program, data can be accessible within the object and which in turn assures the security of the code. 
8. In java, what is the difference between Initialization and Assignment?
 Initialization can be done only once whereas Assignment can be done as many times. 
9. What is casting in java?
 Casting is used to convert the value of one data type to another data type. 
10. What is the difference between a parameter and an argument?
Parameter: To define methods, variables passed in the method are called parameters.
Argument:  While using defined methods, values passed to those variables are called arguments. 
11. What is use of finalize() method?
In java, finalize () method is used just before destroying object and can be called prior to garbage collection. 

12. What is the difference between super() and this()?
Programmers use this() to invoke a constructor of the same class while super() can be used to invoke a super class constructor. 

13. What is the difference between subclass and super class?
 A super class can be inherited whereas sub class cannot be inherited

14. What is the difference between thread and process?
 Thread is a separate path of execution in a program.
Process is a program in execution. 

15. What is synchronization?
Synchronization is the process that ensures that only one thread is accessed by the resources at a time. 

16. What is deadlock condition?
 While executing any program two threads are waiting each other and can’t precede this condition is said to be deadlock. 

17. Using which method you set security in applets?
 using setSecurityManager() method 

Comments

Popular posts from this blog

Rumors of women’s hair cutting in India

President of India