Pages

Thursday, June 16, 2011

JAVA Interview Questions & Answers :


JAVA Interview Questions & Answers :

1. What is the difference between Abstract class and Interface?
A class implementing an interface must implement all of the methods defined in the interface while a class extending an abstract class need not implement any of the methods defined in the abstract class. Additionally a class extending an abstract class can implement an infinite number of it's own methods.

2. what is a transient variable?
A variable that won't be allowed for object serialisation. so that the state of the value will always be defaulted after the deserialisation.
For example a variable x's value is set to 9, it's default value is '0' say, when the object has been serialized having x's value 9, after deserialisation will be defaulted to '0' .

3. WHAT IS THE DIFFERENCE BETWEEN MULTI-THREADING AND MULTI-PROCESSING?

Multitasking is running several processes at a time. Multi threading runs several threads of a single process at a time.The priority levels of threads are from 1-10.Normal priority comes to 5. Multi threading is normal in any window environment otherwise the screen would stuck everytime you clicked on something until that execution was accomplished.

4. Does Java has pointer?.
Java do have pointers; but not similar to the one that C has. In Java Pointers are in the form of Objects/references. Also the pointers in Java are not explicit like C. probably JVM internally uses pointers. Every object is a reference to a location making it a pointer...these pointers cannot be directly manipulated.

Differences between the C & Java pointers:

1) A pointer is a variable that holds the memory address of data. In Java 
there are only references which do not hold any memory address but 
which are indices in a table and this table has then the real pointer to 
the data.

2) Pointer Arithmetic is not possible with Java pointers.

5. Can we make construtor STATIC?
You cannot make a constructor as STATIC because if you use any access modifier in constructor compiler interprets it to be a method and expects a return type this class will not compile until you specify a return type since compiler thinks it to be a normal method not a constructor.

6. what is the differance between equals() method and ==?
The operator checks to see if two objects are exactly the same object. Two strings may be different objects but have the same value.The .equals() method to compare strings for equality(content).


7. Is it true the JAVA is realy a plateform indepandent?
No java is not platform independent it looses platform-independeny in 3 cases 

1. while using threads
2. while using AWT components
3. while using native methods 

also one more question 
we know java looses platform independency while running as threads 
but we also knew that in java every application run as a thread then how can we consider java as a platform-independent language?

8. when does JIT plays its role. Does JIT come along with jdk? If so then what is role of nterpreter?
JIT - Just In Time compiler is embedded in the web browser like the internet explorer!

The interpreter for Java which executes the Byte Codes is the JVM - Java Virtual Machine.

JIT is also a part of the JVM and it compiles bytecodes into real-time code when needed as on demand. The entire Java program is not compiled into an executable code at once coz there need to performed various run-time checks. However JIT compiles code as and when needed during execution. To put it simply the JIT compiler is faster than the JVM.

JIT comes into play when you execute applications written in JavaScript.
9. Does a class inherit the constructors of its superclass ?
A super default constructor is automatically available to the subclass when the subclass object is created. but if you want to access super class parameterized constructors we must use super keyword.
Advantage of servlets over JSP ?
Both the technologies are server side technologies each of them has its own advantages.The basic advantages of Servlet over JSP are

1) The execution time required in the servlet is lesser than because jsp is derived from the servlet so when client makes a request first time to the specific jsp file the container will perfom three steps a)Translation b)Compilation c)construction where as in the servlet these steps are not required except construction.

2) A servlet can handle different dynamic pages where as the jsp can handle only on dynamic page.

11. can we use final keyword before constructor?
generally final keyword is used when we want not to override the class or not to over ride the subclass methods but Constructor have the methods or datamembers to activated when we instantiaed so final keyword should not use before constructor.... and also it does not take final k'word before constructor .

12. What is final class ?
A class which cannot be inherited by any other class is called a final class.

13. What is the difference between static variable and instance variable?
Static variable the field is allocated when the class is created. It belongs to the class and not any object of the class. It is class variable

Instace variable the field is allocated when the class is instanciated to the class is called instance variable or non-static variable

14. Does garbage collection guarantee that a program will not run out of memory?
Garbage collection does not guarantee that a program will not run out of memory. It ispossible for programs to use up memory resources faster than they are garbage collected.It is also possible for programs to create objects that are not subject to garbage collection.


15. What is the significance of null interface in Java?
we say this as an mark up interface we use this interface because it shouid be recognized by Java Virtual Machine in order to make the objects selected for network enable and serialized and select particular objects to be participated in Client/server Communication.
16. Why is the main() method declared public and static?
Main is declared public because JVM accesses this method.

it is declared static because it is instance independent.

17. How does multithreading take place on a computer with a single CPU .
The operating system's task scheduler allocates execution time to multiple tasks. Byquickly switching between executing tasks, it creates the impression that tasks executesequentially.

18. What is the Advantage of using sendRedirect than RequestDispatcher ?
sendRedirect used with response object where Requestdiapacther used with request object.

19. What are some alternatives to inheritance?
Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn't force you to accept all the methods of the super class: you can provide only the methods that really make sense. On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass).

20. What is the difference between Java and J2EE? Is J2EE advanced version of Java?
Java is a object-oriented programming language which is platform neutral. That is unlike C or C++ java programs, Java can be run on any operating system with its JVM.

J2EE is just a specification for server side programs. That is to support internet applications, distributed and uses component model. So that Enterprises use this server side technology in their distributed business.

Since J2EE is just a server side specification, anybody can implement the specification but again using Java.
Hence today we have Custom implemented J2EE servers from Oracle, SUN, IBM and so on..

21. What is the difference between Classpath and Import?
Difference b/w the Classpath and Import:

Classpath: Class path is a system variable. It is a collection of files in the directories.Normally classpath will be used by Java interpreter to exucute the class files(.class).

Import :Import is a keyword. It is used to getting the required files into the program without writing the hard code.
eg. import java.io.*;

22. Why Java is not 100 % pure OOPS?
A pure Object Orientad Language is which implements All the OOP concepts.
Java doesn't support Multiple Inheritance & Operator loading
thats why "Java is not 100% pure Object Language".

23. What is Anonymous class,Singleton Class and Assertions?
Anonymous: instantiating the class without object name.
Singleton: it can instantiated by only one time.

Assertions: to show warning to the user.




--
Thanks and regards,
S.KARTHIKESAN


No comments:

Post a Comment

Labels

.resume (CCL) (engg) (finance) (NTPC) (www.bajajallianzlife.co.in) (www.carpeltechnologies.com) (www.empresscyber.com) (www.hcltech.com) (www.infosys.com) (www.mu-sigma.com) (XHTML) /Instructor 2009/2010 2010 2010- 2011 2011batch 2nd 2nd/3rd 3rd Academy Accent Accenture Accountant Accounts Admin ADP-Freshers Agent Allianz Alpine Analyst Andhra Applicatio​ns Aptel Aquaculture Archieve Assistant Augusht august Authority Bajaj bangalore Bangalore Banking batch Batch Beans BHEL Bhilai Bhopal Bombardier Bosch branches Bureau Business campus CAMPUS Careers Carpel Cements Center Central Chennai Chester Chief Civil clients Coalfields Coastal Cognizant Common Concurrent Consultancy Consultant Consulting Convent Coordinator Court Current Customer Cybernetic DCKAP Dehradun Delhi Delhi/NCR Dermatologist Design details Developer Development Digiblitz Digital Director disabilities DOEACC Drive Economist Electrical Empress Emtex Engineer Engineering Engineers Engineers: Exam.-2011 Exclusive Executive experiecnce experience Experienced Factory Finance Firstsource Ford Format Fresher Fresher-Moksha Freshers friends Government Grade-II/Executive graduate Graduates Group’s Gujarat Gurgaon guys Guys Gynecologist Hiring hospitality hotel ICFRE ICICI IGATE IMAGE Impressive India Indore Industrial infinite Infopro Information Infosys Infotech Insurance Intelligence Interview iOPEX Itarsi Java/J2EE Jnport Job4all jobs Jobs Judge Judicial July Karnataka Kolkata KSRTC lakhs Lakhs Latest Leprosy Librarian Libsys Limited link linux Livicsa Machinary Madras Manager Manual Manufacturing Marketing master Materials Mechanical Mechsoft Mills Mission Moksha month MphasiS Mumbai Muthoot Nagpur NALCO National Nettpositive Nirvana Noida Northern Odisha Officer Officer-2011 Officers Opening Openings Ophthalmologist opportunities Oracle Ordnance Orissa Outdoor Painting Paper passed Performance Personnel POOLED Post) posting Posts Power Pradesh Probationary problem process Process process. Professionals Project Punjab Qualcomm Questions Rayagada Recritment recruiting Recruitment Recruits recuriting Refer registration Representatives required requires RESIZING restaurant Resume Robert Saadhvi Salary Sales Sapient School Section seeking Senior Services Shimla Sigma Simple SKATING Software Solutions Specialist SPORTS supervisor Support Surgeon Synechron Systems TAEKWONDO TEACHER technical Technologies Technology Tendering Testers Testing Thermal Thsti Trainee Trainer Trust Urgent Uttarakhand vacancies vacancy verizon Voice walk-in Walk-in walkin Wipro www.aptel.gov.in www.bgsbuniversity.org www.ciil.org www.cirtindia.com www.detgujarat.org www.hc.ap.nic.in www.icfre.org www.iica.in www.iitb.ac.in www.jnport.gov.in www.jobs.undp.org.in www.karnatakajudiciary.kar.nic.in www.kmrc.in www.ksrtc-jobs.com www.ncl.gov.in www.thsti.res.in