Category: Java

Rule number one : don’t screw around with the browser of your enduser. Say that you were able to filter out the print menu item. What about the keyboard combination ctrl + P? You could override that again with some javascript but that only leaves the enduser clueless as you’re overriding standard functionality and that’s a big nono.

Besides that, you’re using javascript. That can be turned off by an enduser and then your clipboard erasing script also doesn’t work anymore. Poof and there goes your protection level.

try it . .

Thank you


for firefox try as below:


    • 1

      Make sure the new media player is installed on your computer. Popular media players include Real Player, QuickTime, Windows Media Player and WinAmp.

    • 2

      Open Mozilla Firefox and click “Tools” and then “Options” on the main menu.

    • 3

      Click the “Applications” tab. Scroll down on the list of file types until you find all of your media file types, including playlists, audio and videos.

    • 4

      Select the “Action” column box next to each of your media file types. You will see a drop-down box.

    • 5

      Change your default media player for each file type by clicking “Use other.” Choose “Always Ask” from the list if you want the browser to ask you every time which media player you want to use, or choose “Save File” if you want to automatically save the file to your computer instead of opening it.

    • 6

      Press “OK” to close the dialog box. Close and restart your browser to activate the new settings. Click on a song or video file in your browser to make sure it recognizes your choice from Step 4 and opens the file in your new default media player.

Thank you . .

Interface is in java

Interfaces have another very important role in the Java programming language. Interfaces are not part of the class hierarchy, although they work in combination with classes. The Java programming language does not permit multiple inheritance (inheritance is discussed later in this lesson), but interfaces provide an alternative.

Using interface, you can specify what a class must do, but not how it does it.

java does not have multiple inheritances

Inheritance gives us two things:

  • Code reuse
  • Ability to represent the object polymorphically.

Interface supports the concept of multiple inheritance

  • An interface specifies a list of one or more methods, giving only their signatures, but no code
  • A class implements an interface if it supplies code for all methods of that interface


public interface Stack{

public Boolean isEmpty();


Class myStacks implements Stack{




An interface can be sub-interfaced from other interfaces ,sub-interfaced will inherit all members of superinterface:


Interface class2 extends class1


body of class2


Classes Interface
  • A class can extend only one class
  • A class can implement any number of interfaces
  • A class have fields
  • An interface cannot have fields
  • A class defines its own constructors (or it gets a default constructor).
  • An interface has no constructors
  • A concrete class has all its methods defined. An abstract class usually has one or more abstract methods
  • All methods declared in an interface are abstract
  • Every class is a part of a hierarchy of classes with object at the top
  • An interface may belong to a small hierarchy of interfaces, but this is not as common.

Advantages of Interfaces:

  • It provides a standard set of methods for a group of classes.
  • Objects of these classes can be accessed by the standard set of methods without considering about their location in hierarchy.
  • Support selective multiple inheritance.


Object class in Java

Class Object is the root of the class hierarchy. Every class has Object as a super class. All objects, including arrays, implement the methods of this class.


Every class in the Java system is a descendent (direct or indirect) of the Object class. The Object class defines the basic state and behavior that all objects must have, such as the ability to compare oneself to another object, to convert to a string, to wait on a condition variable, to notify other objects that a condition variable has changed, and to return the object’s class.


Object is a super class of all other languages. This means that a reference variable of type Object can refer of any other class.

Object defines the following methods, which means that they are available in every object.





clone( ) :  It creates a new object, which is same as the Object being cloned.


equals( ) :it checks whether the object is equal or not.

finalize( ):the method is called by the garbage collector when it determines no more references to the object exist.

getClass( ) : it gets the class of an object at runtime.

hashcode( ) :it returns the hash code associated with the invoking object.

toString( ) :returns the string which describes the object

wait( ) :waits till another thread to complete execution

notify ():it resumes execution of a thread waiting on invoking object

notifyAll( ):it resumes execution of all threads waiting on the invoking object.

Google Gives $5M Worth of Java GUI Tools to Eclipse

Google has donated two open-source Java tools to the Eclipse Foundation to join the popular IDE suite in 2011.

The tech giant’s WindowBuilder and CodePro AnalytiX were part of Google’s acquisition of Instantiations in August this year. By September, Google had relaunched some of Instantiations’ tools as open-source software.

One of those tools was WindowBuilder, a WYSIWYG code generator. This drag-and-drop, bidirectional GUI designer for Java played nicely with a variety of frameworks, including Swing, XML Windowing Toolkit (XWT), the Standard Widget Toolkit (SWT) and more. With support for Windows , Linux  and Mac, the Eclipse extension was intended to make Java app creation a lot simpler and faster.

And CodePro is another interesting Eclipse plugin for “comprehensive automated software code quality and security analysis.” The toolkit included features from EclipsePro Audit and EclipsePro Test and generally attempted to improve code quality, maintenance and readability.

Instatiations’ execs estimate the software, which is slated to roll out with the rest of the Eclipse June 2011 release train, is worth around $5 million.

Google’s emphasis on Java tools is hardly surprising; the blockbuster success of the Android platform (and sometimes harsh criticism of the Android Market of apps) has practically mandated a focus on Java, which is a big part of the Android stack. Giving devs better Java tools free of charge is an investment in the future of Google’s own platforms.

That’s not to say either of these Eclipse extensions is, in itself, going to be directly used for Android applications; we’re not sure either tool is intended for mobile development. But better tools make better Java devs, who in turn are better equipped to make more and better Android apps.


A class that is missing definitions for one or more methods. You can’t thus create an object of that class. You must first create a subclass and provide definitions for the abstract methods. Unlike interfaces, abstract classes may implement some of the methods. Though you can’t instantiate an abstract class, you can invoke its static methods.
An abstract class cannot instantiated in other words nobody can ever make a new instance of that class . you can still use that abstract class as a declared reference type,for the purpose of polymorphism.
Abstract Methods:

● Methods that do not have implementation (body)

● T0 create an abstract method, just write the methoddeclaration without the body and use the abstractkeyword– No { }

● For example,
// Note that there is no bodypublic abstract void someMethod();

An abstract class has no use ,no value and no purpose unless it it extended.
The reason for using first of all abstract class or interface insted of simple class is to provide “Reusability” i.e. we can use the same interface or abstract class for more than one classes without making any changes in the body of the abstract class or interface. As by using the concept of Inheritance in Java, we use both of them by:
1. Extending the Abstract Class &

2. Implementing the interface
Now, in case of Abstract class, we declare one or more method of that class as “abstract” and all those methods we need to override in the class where we are extending the abstract class. But one limitation still remains here that we can not extend more than one class at a time for a single class i.e. we can not have the functionality of more than one class in the single class at a time.
To overcome this, for providing multiple inheritance concept, we use “Interface“. It is possible to implement more than once interface in one class. Just we need is to override all the methods declared in the interface in the class where we are implementing the interface because when we create an interface, the methods declared in it implicitly becomes Abstract and Final.

public class AppletDemo implements ActionListener, FocusListener{

In the above example, we are implementing two interfaces ActionListener and FocusListener at the same time in one class.
So, ultimate goal of using both abstract class and interface concept is to have Reusability of any kind of function that we want to provide to any of the class.

Data – types in Java

Java supports both primitive and non-primitive variables.Primitive variables are byte,short,int,long,float,double,boolean,char.
primitive variables are declared as:

Datatype variable;
example:     int a;

but how non-primitive variables declare? it means how objects are declared ?there is 3 steps of object creation and assigning
Mobile mob= new Mobile();
1st step:  Mobile mob;
its declaring a reference variable,it tells JVM (Java Virtual Machine) to allocate space for reference variable and names that variable mob.
2nd step:             new Mobile();
it is creating object,it tells the JVM to allocate a space for a new Mobile object on the heap.
3rd step:             Mobile mob = new Mobile();
it is linking the object and the reference.

Primitive variable represents the actual value of the variable, whereas object reference variable represents  a way to get to the object.

Objects and arrays in java actually will hold a reference only, in java all the raw data types passed to a method are call by value and all the object/array data types passed to a method are call by reference.

Geeks around the world are involved in coding, development of various applications using object oriented programming or OOP which we call it shortly. We are all aware of OOP concepts, Polymorphism, Inheritance,Abstraction,Encapsulation etc.

Their are many mission critical applications which are running based on OOP like Java,C++,Dot Net many to mention in this category.


What was the need for functional programming concept,what are the factors the forced the development community to come up with functional programming concepts?

Before I explain the difference between functional programming(FP) and OOP, let me let you what is functional programming,what are the functional programming language.

The functional programming paradigm was explicitly created to support a pure functional approach to problem solving. Functional programming is a form of declarative programming. In contrast, most mainstream languages, including object-oriented programming (OOP) languages such as C#, Visual Basic, C++, and Java –, were designed to primarily support imperative (procedural) programming.

A developer writes code that describes in exacting detail the steps that the computer must take to accomplish the goal. This is sometimes referred to as algorithmic programming. In contrast, a functional approach involves composing the problem as a set of functions to be executed. You define carefully the input to each function, and what each function returns.

Advantages of Pure Functional Programming

  • Increased readability and maintainability. This is because each function is designed to accomplish a specific task given its arguments. The function does not rely on any external state.
  • Easier reiterative development. Because the code is easier to refactor, changes to design are often easier to implement. For example, suppose you write a complicated transformation, and then realize that some code is repeated several times in the transformation. If you refactor through a pure method, you can call your pure method at will without worrying about side effects.
  • Easier testing and debugging. Because pure functions can more easily be tested in isolation, you can write test code that calls the pure function with typical values, valid edge cases, and invalid edge cases.

When do you choose functional programming over object oriented?

  • Object-oriented languages are good when you have a fixed set of operations on things, and as your code evolves, you primarily add new things. This can be accomplished by adding new classes which implement existing methods, and the existing classes are left alone.
  • Functional languages are good when you have a fixed set of things, and as your code evolves, you primarily add new operations on existing things. This can be accomplished by adding new functions which compute with existing data types, and the existing functions are left alone.

What are the typical problem definitions where functional programming is a better choice?

Functional languages excel at manipulating symbolic data in tree form. A favorite example is compilers, where source and intermediate languages change seldom (mostly the same things), but compiler writers are always adding new translations and code improvements or optimizations (new operations on things). Compilation and translation more generally are “killer apps” for functional languages.


Suggested Reading

Online Resources:




• A class can be defined in terms an existing class.

• The new class gets all of the methods and state variables of the old classby default.

• The new class can add new methods and state variables.

• The new class can redefine methods and state variables of its parent.

• No multiple inheritance

•Interfaces provide the good features of multiple inheritance.

A super class is basically the same as any other class in Java, except that we know thatwe want other classes to be created from it. Don’t worry about how that’s done yet; firstlet’s just see what a super class can look like.

But wait, that looks like just a normal class? That’s right. A superclass can look like anytypical class. So, the magic of the superclass does not lie within the superclass itself, butwithin the subclass. You can call Super class as a Parent class.
A subclass is a child of the parent class. Essentially, subclasses come from theirsuperclasses. Subclass draws the characteristics from the parent class in other words .
An simple example of inheritance
The following class extends the definition of a Point to three dimensions.
class Point3D extends Point {

double z;
Point3D (double x, double y, double z) {

this.x = x;

this.y = y:

this.z = z;

public double length() {return Math.sqrt(x*x + y*y + z*z);}

• The x and y values of the point values come from Point automatically.

• The getX and setX methods from Point do not have to be rewritten.

• The length method needs to be redefined.

• The addPoints method can be retained, but an addPoints3D needs to beadded.
Inheritance and instantiation

• Inheritance and instantiation are unrelated.

• Class (object blue prints) have a strict hierarchy (no multipleinheritance).

• Objects can instantiate other objects irrespective of the class hierarchy.

• The instantiating object points to the instantiated object, but otherobjects may also point to the instantiated object so there is no stricthierarchy of objects.

• Objects become garbage when they are no longer pointed to.

Constructors & parameter passing in Java

All classes have at least one constructor. A constructor is used to initialize a new object of that type and has the same name as the class.
A Constructor Is a Special Memeber Function Used To Initialize a New Object Belonging To The Class.

To create a constructor, define a block of code with the same name as the class. For example, the following defines the construtor for a class called “Painting”.

To invoke a constructor, use the “new” keyword, followed by the name of the class.

When creating a Java constructor, remember the Java Constructor Rules.

1) The name of the constructor must be the same as the class name for which the constructor is being defined.
2) The constructor must not define a return type.
3) If a constructor is not defined for a class, the compiler creates a default constructor. This default constructor contains no arguments.
4) If a constructor is defined for class, the compiler does not create a default constructor.
5) Overloaded constructors may be created but there cannot be two constructors in the same class with the same argument list.


class box{

int x;

void area() {



class Boxdemo {

public static void main(String[] args){

box ob1=new box();

box ob2;ob2=new box();



There is a class named ‘box’. And File name is ‘’.There is a object ‘ob1’ Creation at Run Operator Allocates a Memory at Run Time for an Object(ob1) and Return a Reference to it.Here box() is a Default Constructor.

There is Only a Reference Variable ‘ob2’.It create At Compile Time. This ‘ob2’ Contains a Null Value.
It allocates a box Object.Now ‘ob2’Holds The Memory Address of ‘box’ object.
Parameter passing :

This is another common question on Java newsgroups, made worse by the fact that people who should know better still perpetuate the following False:
False: “Objects are passed by reference, primitives are passed by value” Some proponents of this then say, “Ah, except for immutable objects which are passed by value [etc]” which introduces loads of rules without really tackling how Java works. Fortunately the truth is much simpler:
True: Everything in Java is passed by value. Objects, however, are never passed at all. That needs some explanation – after all, if we can’t pass objects, how can we do any work? The answer is that we pass references to objects.
True: The values of variables are always primitives or references, never objects. This is probably the single most important point in learning Java properly. It’s amazing how far you can actually get without knowing it, in fact – but vast numbers of things suddenly make sense when you grasp it.
When people hear the words “pass by reference“, they may understand different things by the words. There are some pretty specific definitions of what it should mean, however. Dale King sometimes quotes this one: “The lvalue of the formal parameter is set to the lvalue of the actual parameter.” (Dale’s formal analysis of this whole question can be found at the bottom of this page.) This would mean that if you wrote the following code:

Object x = null;

giveMeAString (x);

System.out.println (x);

void giveMeAString (Object y){

y = “This is a string”;


the result (if Java used pass-by-reference semantics) would be This is a stringinstead of the actual result: null

Explaining the two true things above eliminates all of this confusion.

%d bloggers like this: