java interview questions

1. What is the difference between private, protected, and public?

These keywords are for allowing privileges to components such as java methods and variables.
Public: accessible to all classes
Private: accessible only to the class to which they belong
Protected: accessible to the class to which they belong and any subclasses.
Access specifiers are keywords that determines the type of access to the member of a class. These are:
* Public
* Protected
* Private
* Defaults

2. What’s the difference between an interface and an abstract class? Also discuss the similarities. (Very Important)

Abstract class is a class which contain one or more abstract methods, which has to be implemented by sub classes. Interface is a Java Object containing method declaration and doesn’t contain implementation. The classes which have implementing the Interfaces must provide the method definition for all the methods
Abstract class is a Class prefix with a abstract keyword followed by Class definition. Interface is a Interface which starts with interface keyword.
Abstract class contains one or more abstract methods. where as Interface contains all abstract methods and final declarations
Abstract classes are useful in a situation that Some general methods should be implemented and specialization behavior should be implemented by child classes. Interfaces are useful in a situation that all properties should be implemented.

Donwload Free PassGuide Braindumps-The Most Realistic Practice Questions and Answers,Help You Pass any Exams

Differences are as follows:

* Interfaces provide a form of multiple inheritance. A class can extend only one other class.
* Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
* A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
* Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual class. Abstract classes are fast.

Similarities:

* Neither Abstract classes or Interface can be instantiated.

How to define an Abstract class?
A class containing abstract method is called Abstract class. An Abstract class can’t be instantiated.
Example of Abstract class:

abstract class testAbstractClass {

PassGuide Cisco Exams Questions & Training Materials

  1. Free java interview questions
  2. Free SCJP 5.0 Exam Objectives
  3. Free Java J2EE Training for JDBC, Java Database Connectivity, RMI and COBRA
  4. Free Passguide Microsoft MB4-535 v2.73
  5. Free SCJP 1.4 Certification Exam
  6. Free SCJP 1.4 Certification Exam Objectives
  7. Free CBT Nuggets: Java – SCJP Certification Package
  8. Free Sap Basis 100 Interview Questions & Ans
  9. Free SAP and Oracle Interview Questions
  10. Free Sap Basis 100 Interview Questions & Ans
  11. Free ABAP Certification Review & Interview Questions, Answers
  12. Free Complete Java 2 Certification Study Guide (3rd Edition)

About the Author

PassGuide Free Certification Exam Download has written 11070 stories on this site.

If you have any doubts about legality of content or you have another suspicions, feel free to contact us:CertGuard@Gmail.com

Write a Comment

Gravatars are small images that can show your personality. You can get your gravatar for free today!

Copyright © 2012 CertBible – IT certifications Exams,Study Guide,Practice Test,Training Materials.. PassGuide,Testinside,Pass4side,Certifyme,Transcender,Examworx,Topcerts,Actualtests. Cisco microsoft Comptia CCNA CCIE MCSE Oracle ccnp hp ibm citrix Sitemap