Entries from August 2010

If a class is located in a package, what do you need to change in the OS environment to be able to use it?

On August 31, 2010 / By admin / In Java / No Comments
You need to add a directory or a jar file that contains the package directories to the CLASSPATH environment variable. Let’s say a class Employee belongs to a package com.xyz.hr; and is located in the file c:\dev\com\xyz\hr\Employee.java. In this case, you’d need to add c:\dev to the variable CLASSPATH. If this class contains the method Read More...
Tags:

How to define an Interface?

On August 30, 2010 / By admin / In Java / No Comments
In Java Interface defines the methods but does not implement them. Interface can include constants. A class that implements the interfaces is bound to implement all the methods defined in Interface. Emaple of Interface: public interface sampleInterface { public void functionOne(); public long CONSTANT_ONE = 1000; } Read More...
Tags:

How to define an Abstract class?

On August 29, 2010 / By admin / In Java / No Comments
A class containing abstract method is called Abstract class. An Abstract class can’t be instantiated. Example of Abstract class: abstract class testAbstractClass { protected String myString; public String getMyString() { return myString; } public abstract string anyAbstractFunction(); } Read More...
Tags:

What is similarities/difference between an Abstract class and Interface?

On August 28, 2010 / By admin / In Java / No Comments
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 Read More...
Tags:

SEO Powered By SEOPressor