Tuesday, June 7, 2011

Running a Java Program from Command Prompt

  • Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file HelloWorld.java with the following text:
    public class HelloWorld
    {
    public static void main(String[] args)
    {
    System.out.println("Hello, World!");
    }
    }
  • Save your file as HelloWorld.java in C:\mywork. To make sure your file name is HeloWorld.java, (not HelloWorld.java.txt), first choose "Save as file type:" All files, then type in the file name HelloWorld.java.

  • Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
    C:\> cd \mywork
    This makes C:\mywork the current directory.
    C:\mywork> dir
    This displays the directory contents. You should see HelloWorld.java among the files.
    C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
    This tells the system where to find JDK programs.
    C:\mywork> javac HelloWorld.java
    This runs javac.exe, the compiler. You should see nothing but the next system prompt...
    C:\mywork> dir
    javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
    C:\mywork> java HelloWorld
    This runs the Java interpreter. You should see the program output:
    Hello, World!

    If the system cannot find javac, check the set path command. If javac runs but you get errors, check your Java text. If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java HelloWorld command. Java is case-sensitive!

Saturday, May 28, 2011

Java vs. C++



The differences between the C++ and Java programming languages can be traced to their heritage, as they have different design goals.

C++ :-
C++ was designed for systems and applications programming, extending the C programming language. To this procedural programming language designed for efficient execution, C++ has added support for statically-typed object-oriented programming, exception handling, scoped resource management, and generic programming, in particular. It also added a standard library which includes generic containers and algorithms.

Java :-
Java was created initially as an interpreter for printing systems but grew to support network computing. Sun Microsystems used it for the basis of their "HotJava" thin client system. It relies on a virtual machine to be secure and highly portable. It is bundled with an extensive library designed to provide a complete abstraction of the underlying platform. Java is a statically-typed object-oriented language that uses a syntax similar to C++, but is not compatible with it. It was designed from scratch, with the goal of being easy to use and accessible to a wider audience.

The different goals in the development of C++ and Java resulted in different principles and design trade-offs between the languages. The differences are as follows :

Java versus C++: General programming issues

Java C++
Method bodies must be defined inside the class to
which they belong.
Method bodies must be defined inside the class to
which they belong.
No forward referencing required. Explicit forward referencing required.
No preprocessor. Heavy reliance on preprocessor.
No comma operator. Comma operator.
No variable-length parameter lists. Variable-length parameter lists.
No optional method parameters. Optional function parameters.
No const reference parameters. const reference parameters.
No goto goto
Labels on break and continue. No labels on break and continue.
Command-line arguments do not include the
program name.
Command-line arguments do not include the
program name.
Main method cannot return a value. Main function can return a value.
No global variables. Global variables.
Character escape sequences can appear in a program. Character escape sequences must appear in a string
or character literal.
Cannot mask identifiers through scope. Can mask identifiers through scope.

Java versus C++: Object-oriented programming
Java C++
Pure object-oriented language. Hybrid between procedural and object-oriented.
All functions (methods) are part of a class. Can have stand-along functions.
No multiple inheritance. Multiple inheritance.
Formal interface specifications. No formal interface specifications.
No parameterized type. Templates as parameterized type.
No operator overloading. Operator overloading.
All methods (except final methods) are dynamically
bound.
Virtual functions are dynamically bound.
Java versus C++: Primitive types
Java C++
Two type categories. Various type categories.
All nonprimitive types are objects. Separate types for structs, unions, enums, and arrays.
All numeric types are signed. Signed and unsigned numeric types.
All primitive types are a fixed size for all platforms. Primitive type size varies by platform.
16-bit Unicode characters. 8-bit ASCII characters.
Boolean data type primitive. No explicit boolean data type.
Conditions must be boolean expressions. Integer results are interpreted as boolean conditions.
Variables are automatically initialized. No automatic initialization of variables.

Java versus C++: Pointers and data structures


Java C++
References, with no explicit pointer manipulation
and no pointer arithmetic.
Pointers, with dereferencing (* or ->) and address (&)
operators.
Array references are not translated to pointer arithmetic. Array references translate to pointer arithmetic.
Arrays automatically check index limits. No automatically array bounds checking.
Array lengths in multidimensional arrays can vary
from one element to the next within one dimension.
Array lengths in multidimensional arrays are all the
same size in a give dimension, fixed by the declaration.
Strings are objects. Strings are null-terminated character arrays.
Built-in string concatenation operator(+). String concatenation through a library function.
Use string concatenation operator for long string literals. Use line continuation (\) for long string literals.
No typedef. typedef to define types.
Java versus C++: Special characteristics
Java C++
Specifically attuned to network and Web processing. No relationship to networks or the Web.
Automatic garbage collection. No automatic garbage collection.
Combination of compiled and interpreted. Compiled.
Slower execution when interpreted. Fast execution.
Architecture neutral. Architecture specific.
Supports multithreading. No multithreading.
Automatic generation of documentation in HTML
format.
No automatic documentation generation

Wednesday, May 25, 2011

One of the best interviews!!!

Interviewer: Tell me about yourself.

Candidate: I am SAMEER GUPTA. I did my Tele Communication engineering from

BabanRao Dhole-Patil Institute of Technology.

Interviewer: BabanRao Dhole-Patil Institute of Technology? I had never heard

of this college before!

Candidate: Great! Even I had not heard of it before getting an admission

into it . What happened is - due to cricket world cup I scored badly! in 12th.I

was getting a paid seat in a good college. But my father said (I prefer to

call him 'baap') - "I can not invest so much of money".(The baap actually said

- "I will never waste so much of money on you"). So I had to join this

college. Frankly speaking this name - BabanRao Dhole-Patil, can at the most be

related to a Shetakari Mahavidyalaya.

Interviewer: ok, ok. It seems you have taken 6 years to complete your

engineering.

Candidate: Actually I tried my best to finish it in 4 years. But you

know, these cricket matches and football world cup, and tennis

tournaments. It is difficult to concentrate. So I flunked in 2nd and

3rd year. So in all I took 4 + 2 = 7 years.

Interviewer: But 4+2 is 6.

Candidate: Oh, is it? You know I always had KT in maths. But I will try

to keep this in mind. 4+2 is 6, good, thanks. These cricket matches

really affect exams a lot. I think they should ban it.

Interviewer: Good to know that you want cricket matches to be banned.

Candidate: No, no... I am talking about Exams!!

Interviewer: Ok, What is your biggest achievement in life?

Candidate: Obviously, completing my Engineering. My mom never thought I

would complete it. In fact, when i flunked in 3rd year, she was looking for a job

for me in BEST (Bus corporation in Maharashtra) through some relative.

Interviewer: Do you have any plans of higher study?

Candidate: he he he.. Are you kidding? Completing 'lower' education

itself was so much of pain!!

Interviewer: Let's talk about technical stuff. On which platforms have

you worked? Candidate: Well, I work at SEEPZ, so you can say Andheri is my current

platform. Earlier I was at Vashi center. So Vashi was my platform then. As you can

see I have experience of different platforms! (Vashi and Andheri are the

places in Mumbai)

Interviewer: And which languages have you used?

Candidate: Marathi, Hindi, English. By the way, I can keep quiet in

German, French, Russian and many other languages.

Interviewer: Why VC is better than VB?

Candidate: It is a common sense - C comes after B. So VC is a higher

version than VB. I heard very soon they are coming up with a new

language VD!

Interviewer: Do you know anything about Assembly Language?

Candidate: Well, I have not heard of it. But I guess, this is the

language our ministers and MPs use in assembly.

Interviewer: What is your general project experience?

Candidate: My general experience about projects is - most of the times

they are in pipeline!

Interviewer: Can you tell me about your current job?

Candidate: Sure, Currently I am working for Bata InfoTech ltd. Since

joining BIL, I am on Bench. Before joining BIL, I used to think that

Bench was another software like Windows.

Interviewer: Do you have any project management experience?

Candidate: No, but I guess it shouldn't be difficult. I know Word and

Excel. I can talk a lot. I know how to dial for International phone call

and use speaker facility. And very important - I know few words like -

'Showstoppers ' , 'hotfixes',

'SEI-CMM','quality','versioncontrol','deadlines' , 'Customer

Satisfaction' etc. Also I can blame others for my mistakes!

Interviewer: What are your expectations from our company?

Candidate: Not much.

1. I should at least get 40,000 in hand.

2. I would like to work on a live EJB project. But it should not have

deadlines. I personally feel that pressure affects natural talent.

3. I believe in flexi-timings.

4. Dress code is against basic freedom, so I

would like to wear t-shirt and jeans.

5. We must have sat-sun off. I will suggest Wednesday off also, so as to

avoid breakdown due to overwork.

6. I would like to go abroad 3 times a year on short term

preferably 2-4 months) assignments. Personally I prefer US, Australia and

Europe. But considering the fact that there is a world cup in West Indies in

2007, I don't mind going there in that period. As you can see I am modest and

don't have many expectations. So can I assume my selection?

Interviewer: he he he ha ha ha. Thanks for your interest in our

organization. In fact I was never entertained so much before. Welcome to

INFO-SYS .. :-))

No intention to offend anybody..

Tuesday, May 10, 2011

How to Catch a LION

Newton 's Method:

Let, the lion catch you.

For every action there is an equal and opposite reaction.

Implies you caught lion.

Einstein Method:

Run in the direction opposite to that of the lion.

Due to higher relative velocity, the lion will also run faster and will get tired soon.

Now you can trap it easily.

Indian Police Method:

Catch any animal and interrogate it & torture it to accept that its a lion.

Rajnikanth Method :

Keep warning the lion that u may come and attack anytime.

The lion will live in fear and die soon in fear itself.

Jayalalitha Method:

Send Police commissioner Muthukaruppan around 2AM and kill it, while it's sleeping !

Manirathnam Method (director):

Make sure the lion does not get sun light and put the lion in a dark

room with a single candle lighted.

Keep murmuring something in its ears.

The lion will be highly irritated and commit suicide.

Karan Johar Method (director):

Send a lioness into the forest.

Our lion and lioness fall in love with each other.

Send another lioness in to the forest, followed by another lion.

First lion loves the first lioness and the second lion loves the 2nd lioness.

But 2nd lioness loves both lions.

Now send another lioness (third) into the forest.

You don't understand right... ok....read it after 15 yrs, then also u wont!

Yash Chopra method (director):

Take the lion to Australia or US.. and kill it in a good scenic location.

Govinda method:

Continuously dance before the lion for 5 or 6 days.

Menaka Gandhi method:

Save the lion from a danger and feed him with some vegetables continuously.

George bush method:

Link the lion with Osama bin laden and shoot him!!!

Rahul Dravid s method:

Ask the lion to bowl at u.

U bat for 200 balls and score 1 run

Lion tires and surrenders

And finally ..

Software Engineer Method:

Catch a cat and claim that your testing has proven that its a Lion.

If anyone comes back with issues tell that you will upgrade it to Lion.

Monday, April 25, 2011

Linux vs. Windows



Topic Linux Windows
Price The majority of Linux variants are available for free or at a much lower price than Microsoft Windows. Microsoft Windows can run between $50.00 - $150.00 US dollars per each license copy.
Ease Although the majority Linux variants have improved dramatically in ease of use, Windows is still much easier to use for new computer users. Microsoft has made several advancements and changes that have made it a much easier to use operating system, and although arguably it may not be the easiest operating system, it is still Easier than Linux.
Reliability The majority of Linux variants and versions are notoriously reliable and can often run for months and years without needing to be rebooted. Although Microsoft Windows has made great improvements in reliability over the last few versions of Windows, it still cannot match the reliability of Linux.
Software Linux has a large variety of available software programs, utilities, and games. However, Windows has a much larger selection of available software. Because of the large amount of Microsoft Windows users, there is a much larger selection of available software programs, utilities, and games for Windows.
Software Cost Many of the available software programs, utilities, and games available on Linux are freeware or open source. Even such complex programs such as Gimp, OpenOffice, StarOffice, and wine are available for free or at a low cost. Although Windows does have software programs, utilities, and games for free, the majority of the programs will cost anywhere between $20.00 - $200.00+ US dollars per copy.
Hardware Linux companies and hardware manufacturers have made great advancements in hardware support for Linux and today Linux will support most hardware devices. However, many companies still do not offer drivers or support for their hardware in Linux. Because of the amount of Microsoft Windows users and the broader driver support, Windows has a much larger support for hardware devices and a good majority of hardware manufacturers will support their products in Microsoft Windows.
Security Linux is and has always been a very secure operating system. Although it still can be attacked when compared to Windows, it much more secure. Although Microsoft has made great improvements over the years with security on their operating system, their operating system continues to be the most vulnerable to viruses and other attacks.
Open Source Many of the Linux variants and many Linux programs are open source and enable users to customize or modify the code however they wish to. Microsoft Windows is not open source and the majority of Windows programs are not open source.
Support Although it may be more difficult to find users familiar with all Linux variants, there are vast amounts of available online documentation and help, available books, and support available for Linux. Microsoft Windows includes its own help section, has vast amount of available online documentation and help, as well as books on each of the versions of Windows.


Advantages of Linux:

  1. Cost – The most obvious advantage of using Linux is the fact that it is free to obtain, while Microsoft products are available for a hefty and sometimes recurring fee. Microsoft licenses typically are only allowed to be installed on a single computer, whereas a Linux distribution can be installed on any number of computers, without paying a single dime.
  2. Security – In line with the costs, the security aspect of Linux is much stronger than that of Windows. Why should you have to spend extra money for virus protection software? The Linux operating system has been around since the early nineties and has managed to stay secure in the realm of widespread viruses, spyware and adware for all these years. Sure, the argument of the Linux desktop not being as widely used is a factor as to why there are no viruses. My rebuttle is that the Linux operating system is open source and if there were a widespread Linux virus released today, there would be hundreds of patches released tomorrow, either by ordinary people that use the operating system or by the distribution maintainers. We wouldn’t need to wait for a patch from a single company like we do with Windows.
  3. Choice (Freedom) – The power of choice is a great Linux advantage. With Linux, you have the power to control just about every aspect of the operating system. Two major features you have control of are your desktops look and feel by way of numerous Window Managers, and the kernel. In Windows, your either stuck using the boring default desktop theme, or risking corruption or failure by installing a third-party shell.
  4. Software - There are so many software choices when it comes to doing any specific task. You could search for a text editor on Freshmeat and yield hundreds, if not thousands of results. My article on 5 Linux text editors you should know about explains how there are so many options just for editing text on the command-line due to the open source nature of Linux. Regular users and programmers contribute applications all the time. Sometimes its a simple modification or feature enhancement of a already existing piece of software, sometimes its a brand new application. In addition, software on Linux tends to be packed with more features and greater usability than software on Windows. Best of all, the vast majority of Linux software is free and open source. Not only are you getting the software for no charge, but you have the option to modify the source code and add more features if you understand the programming language. What more could you ask for?
  5. Hardware - Linux is perfect for those old computers with barely any processing power or memory you have sitting in your garage or basement collecting dust. Install Linux and use it as a firewall, a file server, or a backup server. There are endless possibilities. Old 386 or 486 computers with barely any RAM run Linux without any issue. Good luck running Windows on these machines and actually finding a use for them.
Disadvantages of Linux:

  1. Understanding – Becoming familiar with the Linux operating system requires patience as well as a strong learning curve. You must have the desire to read and figure things out on your own, rather than having everything done for you. Check out the 20 must read howto’s and guides for Linux.
  2. Compatibility – Because of its free nature, Linux is sometimes behind the curve when it comes to brand new hardware compatibility. Though the kernel contributors and maintainers work hard at keeping the kernel up to date, Linux does not have as much of a corporate backing as alternative operating systems. Sometimes you can find third party applications, sometimes you can’t.
  3. Alternative Programs – Though Linux developers have done a great job at creating alternatives to popular Windows applications, there are still some applications that exist on Windows that have no equivalent Linux application. Read Alternatives to Windows Applications to find out some of the popular alternatives.

Sunday, April 24, 2011

Universal Laws(Funny)

1. Law of Mechanical Repair - After your hands become coated with grease, your nose will begin to itch and you'll have to pee.

2. Law of Gravity - Any tool, nut, bolt, screw, when dropped, will roll to the least accessible corner.

3. Law of Probability -The probability of being watched is directly proportional to the stupidity of your act

4. Law of Random Numbers - If you dial a wrong number, you never get a busy signal and someone always answers.

5. Law of the Alibi - If you tell the boss you were late for work because you had a flat tire, the very next morning you will have a flat tire.

6. Variation Law - If you change lines (or traffic lanes), the one you were in will always move faster than the one you are in now (works every time).

7. Law of the Bath - When the body is fully immersed in water, the telephone rings.

8. Law of Close Encounters -The probability of meeting someone you know increases dramatically when you are with someone you don't want to be seen with.

9. Law of the Result - When you try to prove to someone that a machine won't work, it will.

10. Law of bio mechanics - The severity of the itch is inversely proportional to the reach.

11.. Law of the Theater and Hockey Arena - At any event, the people whose seats are furthest from the aisle, always arrive last. They are the ones who will leave their seats several times to go for food, beer, or the toilet and who leave early before the end of the performance or the game is over. The folks in the aisle seats come early, never move once, have long gangly legs or big bellies, and stay to the bitter end of the performance. The aisle people also are very surly folk.

12. The Coffee Law - As soon as you sit down to a cup of hot coffee, your boss will ask you to do something which will last until the coffee is cold.

13. Murphy's Law of Lockers - If there are only two people in a locker room, they will have adjacent lockers.

14. Law of Physical Surfaces - The chances of an open-faced jelly sandwich landing face down on a floor, are directly correlated to the newness and cost of the carpet or rug.

15. Law of Logical Argument - Anything is possible if you don't know what you are talking about.

16. Brown's Law of Physical Appearance - If the clothes fit, they're ugly.

17. Oliver's Law of Public Speaking - A closed mouth gathers no feet.

18. Wilson's Law of Commercial Marketing Strategy - As soon as you find a product that you really like, they will stop making it.

19. Doctors' Law - If you don't feel well, make an appointment to go to the doctor, by the time you get there you'll feel better. But don't make an appointment, and you'll stay sick.

Monday, April 18, 2011

Facts about Anna Hazare and Lok Pal Bill of India



1.Who is Anna Hazare?
An ex-army man. Fought 1965 Indo-Pak War
2.What's so special about him?
He built a village Ralegaon Siddhi in Ahamad Nagar district, Maharashtra
3.This village is a self-sustained model village. Energy is produced in the village itself from solar power, biofuel and wind mills. In 1975, it used to be a poverty clad village. Now it is one of the richest village in India. It has become a model for self-sustained, eco-friendly & harmonic village.
4.This guy, Anna Hazare was awarded Padma Bhushan and is a known figure for his social activities.
5.He is supporting a cause, the amendment of a law to curb corruption in India.
6. How that can be possible?
He is advocating for a Bil, The Lok Pal Bill (The Citizen Ombudsman Bill), that will form an autonomous authority who will make politicians (ministers), beurocrats (IAS/IPS) accountable for their deeds.
8. It's an entirely new thing right?
In 1972, the bill was proposed by then Law minister Mr. Shanti Bhushan. Since then it has been neglected by the politicians and some are trying to change the bill to suit thier theft (corruption).
7. Oh.. He is going on a hunger strike for that whole thing of passing a Bill ! How can that be possible in such a short span of time?
The first thing he is asking for is: the govt should come forward and announce that the bill is going to be passed. Next, they make a joint committee to DRAFT the LOK PAL BILL. 50% goverment participation and 50% public participation.Bcz u cant trust the govt entirely for making such a bill which does not suit them.
8.What will happen when this bill is passed?
A LokPal will be appointed at the centre. He will have an autonomous charge, say like the Election Commission of India. In each and every state, Lokayukta will be appointed.The job is to bring all alleged party to trial in case of corruptions within 1 year. Within 2 years, the guilty will be punished.