Java reference VOL-3


Abstract Methods and Classes

An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.
An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this:
abstract void moveTo(double deltaX, double deltaY);
If a class includes abstract methods, the class itself must be declared abstract, as in:
public abstract class GraphicObject {
   // declare fields
   // declare non-abstract methods
   abstract void draw();
}
When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, the subclass must also be declared abstract.


Note: All of the methods in an interface (see the Interfaces section) are implicitly abstract, so the abstract modifier is not used with interface methods (it could be—it's just not necessary).


Abstract Classes versus Interfaces
Unlike interfaces, abstract classes can contain fields that are not static and final, and they can contain implemented methods. Such abstract classes are similar to interfaces, except that they provide a partial implementation, leaving it to subclasses to complete the implementation. If an abstract class contains only abstract method declarations, it should be declared as an interface instead.
Multiple interfaces can be implemented by classes anywhere in the class hierarchy, whether or not they are related to one another in any way. Think of Comparable or Cloneable, for example.
By comparison, abstract classes are most commonly subclassed to share pieces of implementation. A single abstract class is subclassed by similar classes that have a lot in common (the implemented parts of the abstract class), but also have some differences (the abstract methods).
An Abstract Class Example
In an object-oriented drawing application, you can draw circles, rectangles, lines, Bezier curves, and many other graphic objects. These objects all have certain states (for example: position, orientation, line color, fill color) and behaviors (for example: moveTo, rotate, resize, draw) in common. Some of these states and behaviors are the same for all graphic objects—for example: position, fill color, and moveTo. Others require different implementations—for example, resize or draw. All GraphicObjects must know how to draw or resize themselves; they just differ in how they do it. This is a perfect situation for an abstract superclass. You can take advantage of the similarities and declare all the graphic objects to inherit from the same abstract parent object.

First, you declare an abstract class, GraphicObject, to provide member variables and methods that are wholly shared by all subclasses, such as the current position and the moveTo method. GraphicObject also declares abstract methods for methods, such as draw or resize, that need to be implemented by all subclasses but must be implemented in different ways. The GraphicObject class can look something like this:
abstract class GraphicObject {
    int x, y;
    ...
    void moveTo(int newX, int newY) {
        ...
    }
    abstract void draw();
    abstract void resize();
}
Each non-abstract subclass of GraphicObject, such as Circle and Rectangle, must provide implementations for the draw and resize methods:
class Circle extends GraphicObject {
    void draw() {
        ...
    }
    void resize() {
        ...
    }
}
class Rectangle extends GraphicObject {
    void draw() {
        ...
    }
    void resize() {
        ...
    }
}
When an Abstract Class Implements an Interface
In the section on Interfaces , it was noted that a class that implements an interface must implement all of the interface's methods. It is possible, however, to define a class that does not implement all of the interface methods, provided that the class is declared to be abstract. For example,
abstract class X implements Y {
  // implements all but one method of Y
}

class XX extends X {
  // implements the remaining method in Y
}
In this case, class X must be abstract because it does not fully implement Y, but class XX does, in fact, implement Y.
Class Members
An abstract class may have static fields and static methods. You can use these static members with a class reference—for example, AbstractClass.staticMethod()—as you would with any other class. 


 

Computer Performance Booster Tips

Dear visitor what is your computer speed ? did you ever think about that sometimes it may be higher than of what your computer now have, just like our vehicles if you didn't give proper maintenance it will show it's anger,
In case of our computers also if you didn't give proper settings it will not give you that performance that it actually have.

Here is some tips or some tricks that increase your computer's performance and speed, now everything will get faster.



1.Delete temporary files in the computer.

When the computer performs many tasks like installation of software, software updates and many things like this it will keep a temporary copy or a temporary disk area to perform that particular operation actually these files are not needed to the system when the operation is over. some software automatically deletes these files otherwise it will be a garbage item in our system it reduces the available disk space and reduces computing capacity so delete any temporary files if any.(Start->run->temp and press ok)

   
2.Delete User temporary files.

This is also a temporary file directory where temporary files corresponding to the user are stored delete those files also(Start->run->%temp% and press ok)

3.Delete recent files accessed.

This directory only consist of shortcuts of the recently accessed files.
(Start->run->recent)

4.Perform Disk Cleanup.


Disk cleanup is a utility which cleans up unnecessary files from the drive.
(Start->programs->Accessories->System tools->Disk cleanup) choose all unwanted files and click ok.


5.Perform Disk De-fragmentation.

Disk De fragmentation is a tool which arranges the fragmented files in the disk. when ever we write files into the hard disk it is stored in different locations in the disk, by De fragmenting these files are grouped together and it enables fast access of data from the hard disk.Rather than getting free memory this is a good practice to do De fragmentation.


6.Changing the Folder options.

Goto control panel->folder options.
a)In genaral tab deselect 'show common tasks in folders' and set 'use windows classic folders option'.
b)In view tab deselect 'Automatically search for network folders and printers'.


7.Changing Advanced settings of 'my computer'.

Goto my computer right click and select properties and select advanced and click on performance settings
in that new window deselect items except the following.
i)smooth edges of screen fonts.
ii)smooth scroll list box
iii)use drop shadow for icon labels on the desktop.
iv)use visual style on windows and buttons.


 After this feel the difference and post your experience through comments...

 

Virus and their history

FAMOUS VIRUSES

1.SASSER WORM

This type of virus enters into computer through some ports which are opened by default. SASSER virus invented in the year 2003 which enters into the computers which are installed with windows 2000 and windows xp operating systems.

The fault in these products like 'Buffer overflow' lead them to develop such a virus it automatically enters if the computer has internet connection. when it is entered into the system it automatically shuts down the system. now patch programs are available to prevent such viruses.




2.BEAST (Trogen horse)

This is the first virus which implemented 'Reverse connection' mechanism with this the virus programmer can have full control over the affected system. This virus was developed using Delphi programming language and it was created by Tattaye. Now also some innovated versions of this virus are available.


3. SQL SLAMMER

This virus implemented the method of 'Denail of service' which are mainly used to break the websites. This is invented in the year 2003 and within 10 minutes it is affected by more than 75000 computers which is also having the operating system failure 'Buffer overflow'.

Protection against sql slammer


4.I LOVE YOU virus

This is a mail attached virus which is having the name 'LOVE-LETTER-FORYOU.
TXT.vbs'. it is created using a visual basic script and attached with mails but it will not be having the extension '.vbs' it will be showing the extension '.txt' with that user will suddenly open and the cript will get executed.
it was first found in the year 2000 in Philippians was developed by Reyomel lameras and his friend onel de gusmen. when it attacks a computer it destroys the mail server and mail client and forwards the mail to all contacts and it was a big problem for the business corporates. This virus having a record that the most affected virus in the year 2002.

5. NIMDA virus

 It is the reverse form of ADMIN this virus automatically sends a README.exe file and destroys the web pages and automatically downloaded into the local system when a webpage is visited. It shares the local folders into web servers and changes the functioning of executable files in the system and spreads itself to all other computers. computers including different class of operating systems are affected by this virus.


6. MYDOOM virus

This virus having the record that the fast spreader virus in the year 2004. it spreads through mails which is having the word 'andy; I'm just doing my job, nothing personal, sorry,' which means that the inventor of this virus done this for money or for just a time pass. Russia is the invented country of this virus.
This virus program was created as it will automatically stops its attack on 2002 February 12 and it was used to attack the financial companies in America.