Tuesday 29 October 2013

CAN WE EXECUTE A PROGRAM WITHOUT THE MAIN METHOD ???????

ANSWER TO THE ABOVE LINE IS YES...

I will explain you how it is possible later but before that i want to explain you a main concept of java program that is Static Block.

Static Block:-
            Whenever a block is declared with "static" keyword, it is known as static block in the program..

  • Nature:-
  1. The code inside static block get executed before the execution of main method.
  2. Static block cannot be declared inside any method.
  3. Static block is executed only once
Program:-
class Demo
{
static 
{
System.out.println("It is a static block");
}
public static void main(string args[])
{
System.out.println("It is main method");
}
}

Output:-
It is a static block.
It is main method.

Note:-The line written in pink color in the above program is a static block.

Hope you got the answer of the topic that can we execute a java program without the main method???
The answer is very clear..Yes we can execute a java program without main method with the help of Static Block..
I can give you an example in support of this explanation..
Example: A java program without main method.
class Demo
{
static
{
System.out.println("Hello my reader");
System.exit(0);
}
}

Output:-
Hello my reader

Hence it is clear that we can execute a java program without the main method..

PARAMETERIZED CONSTRUCTOR

Parameterized constructor is used to assign different values to different object of given class.

Program:-
class Rectangle
{
double width;
double height;
Rectangle(double w,double h)
{
width=w;
height=h;
}
double area()
{
return width*height;
}
}
public class RectangleDemo
{
public static void main(String args[])
{
Rectangle rec1=new Rectangle(10,20);
Rectangle rec2=new Rectangle(3,6);
double area;
area=rec1.area();
System.out.println("area is"+area);
area=rec2.area();
System.out.println("area is"+area);
}
}

Output:-
area is 200.0
area is 18.0

Saturday 26 October 2013

INDIA STILL LACKS IN THE RACE OF INTERNET SPEED

It would be tidy to repeat the same line all the time that today internet is something that people can't live without it..But it has again hurted me that we indians are lacking in terms of internet speed in this days also...you would be shocked to hear that INDIA STANDS AT 116th POSITION in the ranking of speed of internet available in the world..South korea is at the top in this ranking with internet speed of 14.2mbps..
And you will be shivering to hear that India is having only 1.2mbps of internet speed..
Oh we are still having a huge margin in internet speed..Do you know whats the reason behind this...The main reason is that India does not have that much bandwith availble to support its large population and the next reason is that it does not have sufficient amount of towers(BTS). Hope india improves its internet speed and we enjoy intenet in a better manner... 

CONSTRUCTOR

A constructor is used to create object through new operator.

Program :-
class Rectangle
{
double width;
double height;
Rectangle()
{
System.out.println("constructing Rectangle");
width=10;
height=20;
}
double area()
{
return width*height;
}
}
class RectangleDemo
{
public static void main(String args[])
{
Rectangle rec=new rectangle();
double area;
area=rec.area();
System.out.println("area is"+area);
}
}

Output :-
constructing Rectangle
area is 200

Note :- In above program line written with blue line is code for creating constructor...i.e
Rectangle()
{
System.out.println("constructing Rectangle");
width=10;
height=20;
}

Friday 25 October 2013

CLASS FUNDAMENTAL

A class is simply a template.
An object is created to give life to the various attributes of a class..

Note:- In Java a class template takes no memory, Memory is allocated when object is created.

Program :- Calculate Area of Rectangle


class Rectangle
{
double width;
double height;
double area();
{
return width height;
}
}
class RectangleDemo
{
public static void main(String args[])
{
Rectangle rec1=new Rectangle();
double area;
rec1.width=10;
rec1.height=20;
area=rec1.area();
System.out.println("Area"+area);
}
}

OUTPUT:-
Area 200.0

Note :- The line written in yellow line is used for creating object of a class..
             where
              rec1- Reference variable
              new- New operator
              Rectangle()- Constructor

Introduction of JAVA

                                              

                                           JAVA

  • History
  1. 1991- James Gosling- called "OAK".
  2. 1995- Developed by Sun Microsystem= Called it "JAVA".
  • Sun Microsystem Launched Different Versions Of Java Based on Different Purposes
  1. J2SE(Standard Edition)     :- Window based Application
  2. J2EE(Enterprise Edition)   :- Web based application
  3. J2ME(Mobile Application) :- Mobile based application
NOTE:- When a java file is compiled, a class file is created, A class file is a collection of Byte code.Bytes codes are then interpreted by JVM.

                 Two process done in execution of a java program:-
                      1) Compilation
                      2) Interpretation

Important features of JAVA :- Platform independent
                                                        means write once run  anywhere 



Wednesday 23 October 2013

WHICH MOBILE IS BEST

Today if we see two companies are at the top choices for the people to buy a cell phone i.e NOKIA AND SAMSUNG..As i have use mobile of both the companies so i am aware with their pros and cons..
Hope this may differ from person to person and i personally don't have any issue with any of this two..
I first bought a mobile of samsung..Camera quality was too good and the feature were more than expected from a mobile of Rs8000...The best part of samsung moble was that it never hanged like nokia mobile..And battery backup was mind blowing..Standby battery backup was upto 3 days..I only found one demerit in that mobile was that sometimes a blue screen appears on the screen..And it also don't support beautiful themes as nokia supports...
After this i bought a nokia mobile 0f Rs7000..Camera quality was less than samsung although both have 3mp camera..The nokia mobile hangs very often and sometimes it is so irritating..Also it has less features than samsung mobile of the same cost..The only thing i liked about nokia is its look and theme supporting property..So if you are fan of looks you can choose nokia and if you are fan of technology you can choose samsung..Battery backup of nokia mobile is also very poor..Stand by time is 1 day or one and half days..

So according to my opinion samsung is best in overall..So my rating to samsung is 4 out of 5 and to nokia is 3 out of 5..But the choice is yours...

Friday 11 October 2013

WHY WE ARE SO MUCH ADDICTED TO FACEBOOK

Today almost 80% of internet users just start their net surfing with the first page opening their facebook account..Isn't it so irritating to hear that most of us are addicted to facebook like drugs...It was a sweet poison that was injected to us few years before and had made us sick of it today..We cant't live without facebook for one day or you can say a single hour...We constantly check our facebook account for silly notifications and updates..I'm not saying that we all are mad of it..But I'm talking about most of them..I don't say that facebook is not good..Ya its good..It has made all of us to connect to rest of the world..But don't you think it has made us stupid too..Instead of doing rest of the works we are busy in facebook..Can you imagine the amount of time given on facebook can be utilised in sharing our valuable time with our family...

But the fact is there was something that facebook became the need of all of us...The world was so busy that we people were left alone with our feelings..It was only facebook who came at the right time to shake hands with us and became our partner...But still i argue with it..Facebook can't replace our valuable work or our other relations...Every thing has a limit and it must also have..Don't you think that we sholud love doing facebook instead of getting addicted to it..Don'y you think so that facebook has made our mind narrow by limiting our feelings to a page...I can't imagine that we people in this era can talk to a wall..Haaa haaaa haaa...Are we mad...We are talking to a non-living thing....I'm not against of it nor a supporter of it..I just wan't to ask you a question...Are we getting addicted to facebook???If your heart says yes then i hope its the right time to control your emotions towards time given to facebook...Just limit your time by starting it from a day to a week...Hope it will keep your love towards facebook instead of making you addicted...Just think over it...