Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Is it possible to write JAVA program without including any
of the packages,such as "import java.io.*";
bcoz I instantly wrote a code without "import..." statement
and runned the program on command Line & it worked.
the code is:
class Person
{
String name;
int age;
Person(String s,int a)
{
name = s;
age = a;
}
accept()
{
System.out.println(name+"Hi!!!!!");
System.out.println(age);
}
}
class Demo
{
public static void main(Strings args[])throws
IOException
{
String name = args[0];
int age = Integer.parseInt(args[1]);
Person p = new Person(name,age);
p.accept();
}
}

Answers were Sorted based on User's Feedback



Is it possible to write JAVA program without including any of the packages,such as "import j..

Answer / anandkumar

No its not Possible. but if you are not using the Exception it will be possible.....

Is This Answer Correct ?    3 Yes 0 No

Is it possible to write JAVA program without including any of the packages,such as "import j..

Answer / shaik baji

HI Vijay Kumar Khadia,

I have tried with your above posted code but it
doesn't work so kindly can you explain me more detailed.

Is This Answer Correct ?    1 Yes 0 No

Is it possible to write JAVA program without including any of the packages,such as "import j..

Answer / appa

In main method "Strings" throws exception nd import is
necessary for above code bcz IOException is Used,
If throws is removed it will execute for sure But at cmd
line if no values are passed then IndexOutOfBoundsException
is raised, so at cmd line u have to pass the values

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the difference between Object and Instance?

5 Answers   TCS,


Give me some null interfaces in java?

0 Answers  


Marker interface means , interface which has no methods.Then what is the necessity of its usage.I read "it tells the compiler that it should be treated differently ". "It is used to store state of an object". But still am not clear.Please explain clearly.

2 Answers  


What is initial size of arraylist in java?

0 Answers  


What is methods in java?

0 Answers  


When we serialize an object does the serialization mechanism saves its references too?

0 Answers  


What an i/o filter?

0 Answers  


Can we start a thread twice in java?

0 Answers  


What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?

0 Answers   Bravura Solutions,


What are operators and its types?

0 Answers  


How to sort a collection of custom Objects in Java?

0 Answers  


Can we have 2 main methods in java class?

0 Answers  


Categories