Friday, June 26, 2009

India IT giants to bid for MultiBillion UIC Project

Indian IT companies are gearing up to bid for Multi Billion UIC(Unique Identification Card) project after government decided to put it on the fast track.In response to The Supreme Court ruling Yesterday Planning commission of India appointed Nandan Nilekani as the project chief and put it on a fast track to complete within 3 years.Nandan co-founder of Infosys is known for his entrepreneurship.The post he is given will be equivalent to that of a cabinet minister.


As soon as he is appointed as project chief he resigned from the co-chairman of Infosys as to avoid any conflict of interest.This project would cost around 10,000 crore rupees and will lift the Indian economy.There was a little pressure from the IT companies too as they were pressing government for restarting such public projects to get some work.Infosys and TCS already have confirmed that they would bid for this project.This project is expected to create almost 1,00,000 jobs in the industry and hence result in more recruitment.This is a combined project for many companies like card manufacturers,printing,chip designing,programmers,network specialists etc.This will all impact the Indian IT scenario and will help make it better.Infosys made it clear that the whole process would be transparent including deals and negotiations after some suspect that Nilekani's presence might give an edge to Infosys to grab the project.

Peoples across the country expressed happiness after they heard about UIC project.This card will include all their details .Now they need to keep just one card despite carrying many.It will have record of your all bank accounts and transactions,your citizen ID,your biometric data and much more.It will contain a chip which will store all your information.After launch of this card their would be no use of ration,PAN and other card.The main benefit is that the poor will be benefited directly.

Although issuing cards to a billion peoples will take time but with the leadership of Mr. Nandan Nilekani we hope it will be completed soon because it is matter of national security that is why it is being given such priority by government.It is a major step towards preventing terrorism.

There is a hope for me too.I have got offer of employment from Infosys.I think the news came just at the right time and I hope Infosys to grab the project because it will make my job safe in such economic downturn.

Read more...

Thursday, June 25, 2009

All about enums:How to create ,How to use -- part 3

We have seen the basics of enum in part 1 and part 2.Now we will see the advanced aspect that how can you use the enum to declare and use the methods,variables within it.

The question is why we need to declare and use methods and variables in enums?
The answer is to specify the functionality of the enum.All the logical code and selection logic must remain within the enum.This is done for increasing the understandability and performance of program.enum is just like a look up table from which the values are fetched based on certain conditions.

Following is the example how we can use methods and variables within enum:-

enum RAM{ BATTERING_RAM(20),CAPPED_RAM(30),SIEGE_RAM(40) };

RAM(int hitpoints){
this.hitpoints=hitpoints;
}

private int hitpoints;
public int getHitpoints(){
return hitpoints;
}

class TestRam{
RAM ramName;
public static void main(String a[]){
TestRam ram1=new TestRam();
ram1.ramName=RAM.SIEGE_RAM;
Syatem.out.println(ram1.ramName.getHitpoints());
}
}

The above example prints output as the hitpoints of SIEGE_RAM as 40.That is how you can use the methods and variables within an enum.

Suggested Links:-
Home
All about enums:How to create ,How to use -- part 1
All about enums:How to create ,How to use -- part 2
Why java classes are not marked "final"

Read more...

All about enums:How to create ,How to use -- part 2

In part 1 we have see we can use the enums in two ways
1.As own class.
2.Within other class.

You can understand the usage in followin examples:-

=>Declaring enum as own class and outside the class:-

enum Processor{ P4,DUALCORE,COREDUO};

class Processorvalue{
Processor process;
}

public class Processortest{
public static void main(String a[]){
Processorvalue pval=new Processorvalue();
pval.process=Processor.P4;
}
}

=>enum declared within a class

class Processorvalue{
enum Processor{P4,DUALCORE,COREDUO};
Processor process;
}

public class Processtest{
public static void main(String a[]){
Processorvalue pval= new Processorvalue();
pval.process=Processorvalue.Processor.P4;
}
}

Note:-Access methods and syntax pattern depend on the way of implementation of enum.

How to use methods and variables within an enum -Part 3

Useful links:-
Home
All about enums:How to create ,How to use -- part 1
Why java classes are not marked "final"

Read more...

All about enums:How to create ,How to use -- part 1

enum is a special kind of class in which we can list enumaerated constant values.We can add constants,methods and instance variables and a brand new stranger called constant specific class body.

enums lets you choose a variable to having one of a few pre-defined set of values.That is selecting one value from an enumerated list.
Simple declaration for an enum is as follows:-

enum Processor{P4,DUALCORE,COREDUO }

to fetch a value from an enum you must use following syntax:-

Processor process=Processor.P4;

Note:-You can put semicolon at the end of curly braces in declaration because they are optional.So whenever you see an enum declaration ending with semicolon never get confused.Remember semicolon is optional.

Rules regarding enums:-
There are some rules while using enums

Rule 1:-enums can be declared as their own seperate class.
Rule 2:-enums can also be a class member.
Rule 3:-enums must not be declared within a method.
Rule 4:-enums can have only to access modifiers
1.defult(which is by default no need to specify)
2.public

There are two ways of using enums
1.As own class.
2.Within a class.

To view examples Proceed to part 2

Suggested Links:-
Home
Why public class not marked "final"
Variables

Read more...

Tuesday, June 23, 2009

Local Variable , Instance Variable and Shadowing

Instance variables and local variables are two types of variables based on variable declaration.

Instance variables are those variables which are declared just below class declaration and are available to all member methods.These are outside any method body.Instance variable are data fields which are unique to each and every object.

For Example:-

public class test{

//Following both are Instance variable of class test ,whenever the class is instantiated these are also initialized
private String name;
private String address;
}

Main points about Instance variables:-

1.We can use any of four access modifiers(public,private,protected,default).
2.Instance variables cannot be either static or abstract.
3.Instance variables can be marked final or transient.
4.Instance variables cannot be marked strictfp,native and synchronized.

Local variables are variables which are declared within a method.This means the variable is initialized within method and also declared within method.Local variable has its scope and lifetime limited to the method.Local variable gets initialized when a method is loaded and destroyed when a method completes.The important thing to remember is that the local variable itself can be passed as argument in other method calls but its scope is limited to its method.Local variables during declaration must be assigned a value otherwise compiler will slap a error that variable not initialized.Local variables life goes inside a stack not on heap.

Note:-Local variables can't ever be referenced in any code outside the method in which it is declared.

For Example:-

//myvalue inside mymethod is a local variable.
public class testlocal{
public void mymethod(){
int myvalue=21;
}
}

Variable Shadowing:-We can declare local variable with the same name as Instance variable.It is known as variable shadowing.These came in often where the local variable is an argument and you wish to assign a value of Instance variable to the local variable.Sometimes you get confused in this(see following):-

public class shadowconfusion{
int age=21;
public void yourage(int age){
age=age; // In this case it becomes difficult to know which value is assigned to which one
}
}

To remove this confusion we use this keyword.this keyword always refers to the object currently running.That is previously written code can be modified as following:-

public class shadowconfusion{
int age=21;
public void yourage(int age){
this.age=age; //Instance variable is assigned a value from parameter.
}
}

Links:-
Home
Why Java Classes are not marked "final"
India Online Latest From India

Read more...

Saturday, June 20, 2009

Why Java Classes are not marked "final"

final keyword is a main feature of Java language.It is mostly used to define the constant values.Since it is a non-access modifier ,then question arises can final keyword be used with the Java classes.The answer simply is no,we can never ever use a final modifier before a Java class but Important thing here is to remember(REALLY IMPORTANT) that if you wish, methods of your class must not be overridden then only use final keyword before class declaration.Declaring a Java class as final means you can never subclass or extend the final class.That is it is strictly against the inheritance property.So does it violate the Object Oriented property of Java?So why we should use it?You should make a final class only if you need an absolute guarantee that none of your methods in that class will ever be overridden.

If you want security of your code and don't want any body to change it ,mark your class as final thus your implementation will remain secret and can never be changed.

The main example here is that the main Java core libraries are also marked as final.Assume a situation where we cannot guarantee that how String class going to work on any system your application is running on.

Use final modifier only when you think that you need no improvements in future because once declared as final a class cannot be subclassed and improved.

Example:-

public final class test{
public void myMethod(){ //your code }
}

class testingtest extends test{ //your code }

Compiling above code snippet would give output like following:-
Can't subclass final classes:class test class testingtest extends test
1 error

As told earlier use final in the extreme conditions where you require quite a lot of safety and security.If your class needs an improvement and you don't have source code, you now better what you have to do!!!!!

Home
Local Variable , Instance Variable and Shadowing
India Online all Indian Stuff

Read more...

Friday, June 19, 2009

How to create pop-up menus in Java

PopUp Menus

Pop-up menus are the menus that are displayed when a user clicks the right mouse button.They are sometimes also known as short-cut menus.
Short cut menus are very handy in cases where some functionality you want to provide like adding a help menu to all controls on right click.

Step for creating Pop-up menus:-

1.Create an object of the JPopupMenu class.
2.Create object of the Menu class for each menu you want to add on the menu bar.
3.Call the add() method of the JPopupMenu class to add each menu object to the pop-up menu.
4.Create objects of the JMenuItem or CheckboxMenuItem class for each item that you want to in the menu.
5.Call the add() method of the Menu class to add each item to its appropriate menu.



Example Source code:-

//PopUpColorMenu.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class PopUpColorMenu
{
Component selectedComponent;

public PopUpColorMenu( ) {
JFrame frame = new JFrame("PopUpColorMenu v1.0");

final JPopupMenu colorMenu = new JPopupMenu("Color");
colorMenu.add(makeMenuItem("Red"));
colorMenu.add(makeMenuItem("Green"));
colorMenu.add(makeMenuItem("Blue"));

MouseListener mouseListener = new MouseAdapter( ) {
public void mousePressed(MouseEvent e) { checkPopup(e); }
public void mouseClicked(MouseEvent e) { checkPopup(e); }
public void mouseReleased(MouseEvent e) { checkPopup(e); }
private void checkPopup(MouseEvent e) {
if (e.isPopupTrigger( )) {
selectedComponent = e.getComponent( );
colorMenu.show(e.getComponent(), e.getX( ), e.getY( ));
}
}
};
frame.getContentPane( ).addMouseListener(mouseListener);

frame.setSize(200,50);
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setVisible(true);
}
private JMenuItem makeMenuItem(String label) {
JMenuItem item = new JMenuItem(label);
return item;
}

public static void main(String[] args) {
new PopUpColorMenu( );
}
}

Useful Links:-
Home
Menus
MenuBars

Read more...

Java Source File Declaration Rules

Declaration Rules

Before doing the hardcore programming one has to be familiar with the rules which govern the source file declaration in Java.Sun Microsystems has provided the guidelines for the naming and declaration.Here we will look the rules which are associated with declaring classes,import statements etc.

Rule 1:- There can be only one public class per source code file(e.g. a Java File).

Rule 2:-If there is a public class in a file then the name of the java file must match the name of public class.For example if you declared public class Man{ } then it must be stored in a file which is also named as Man.java.

Rule 3:-Comments can appear at the beginning or end of any line of code of source code file.

Rule 4:-A source file can have more than one non-public classes.

Rule 5:-If a class is a part of a package,then the package statement must be first line of code,irrespective of any import statement present.
For example:-
package cert;
import java.lang.*;

Rule 6:-If there are import statements then they must go between package and class declarations.If there are no package statements then import statement must be first line of code and if import is also absent then class declaration will be first statement in source file.

Rule 7:-import and package statement apply to all classes within a source file.In other words there in no way to declare multiple classes in a file which have them in different packages and using different imports.

Rule 8:-Files with no public classes can have a name which may or may not match the name of any constituent class.

Home
India Online

Read more...

Monday, June 8, 2009

Last Day at College

Hii friends!!
.
Its a very bad feeling that you are no more with your friends and colleagues .All the joy and laughs is just about to vanish.Today is the final year project presentation,and most probably its the last day at college.I despite getting job offers felling a little scared about my future.Most of my friends got jobs in various firms but some how few missed out on their opportunities.Today everywhere scribbling on college uniform is on you can see the shirts and suits scribbled with funny and serious quotes.Everyone gives a nice feeling.Friends told me that when they left the ppt. hall they were felling joy but after few hours of laughter they were start thinking what is next.I most you have this experience before but still you can know what I am feeling right now.I am also vey much optimistic about my future ,I am in search of some short term job.(coz India is little affect of global meltdown) Which can fetch me some money.So that I can buy myself a Laptop(or a PS3).This job might be of teaching.But I will continue writing Java tutorials as I am writing now.Sorry for being late but I was busy in preparing my project.I know you will forgive me coz it is for right coz.Today I will leave my hostel and go to my home.See you there.

with Regards
Vaibhav

Read more...

About This Blog

This Blog is all about Java and programming.This blog is written by Vaibhav Pandey .He is a Computer Science Graduate .You can contact the author at javatute@gmail.com for any suggestion or Query.You can also contact the author for advertising on this blog.All the material presented here is the property of author and its reproduction in any form is strictly prohibited.

Disclaimer:-Download links provided here are not of author in any means.These are found over the Internet.
Page copy protected against web site content infringement by Copyscape

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP