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 / 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 View All Answers
Are arrays immutable in java?
What is http client in java?
if u open login & logout ,how can udisplay the timelogin & logout members ?
What is complexity in java?
Is Java a dying language?
How do you remove all elements from an arraylist in java?
Explain Basics of OOP Language in java
Can Exception handling we can handle multiple catch blocks?
What is the static variable?
What do you understand by Header linked List?
How do you convert an int to a double in java?
How can we break singleton in java?
How can we create an immutable class in java?
What is flush () in java?
What is a byte string?