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 do you understand by synchronization?

0 Answers  


How is Garbage collection done in Java?

3 Answers   T3 Softwares,


What is the purpose of a parameter?

0 Answers  


What is a programming object?

0 Answers  


Is char a data type in java?

0 Answers  






How big is a gigabyte?

0 Answers  


How many types of syncronization?

2 Answers  


Does constructor creates the object ?

0 Answers  


What is a Null object?

1 Answers   Wipro,


Can an object be garbage collected while it is still reachable?

3 Answers  


what are the different non-access specifiers in java?

5 Answers  


What are the advantages of arraylist over arrays?

0 Answers  


Categories