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();
}
}
Answer Posted / 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 |
Post New Answer View All Answers
Why does java have two ways to create child threads?
Suppose if we have variable ' I ' in run method, if I can create one or more thread each thread will occupy a separate copy or same variable will be shared?
How will you serialize a singleton class without violating singleton pattern?
How does queue work in java?
What does compareto () do in java?
Why we use set in java?
Where and how can you use a private constructor?
What is treemap in java?
What is join () in java?
Tell us something about set interface.
what is the difference between thread and runnable types? : Java thread
Why does java not support operator overloading?
What is a functional interface?
How to sort an array from smallest to largest java?
Can we overload the constructors?