Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Java code?
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new File(“/java/system”);
System.out.print(obj.getName());
}
}

What will be the output of the following Java code?
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new File(“/java/system”);
System.out.print(obj.getName());
}
}
a) java
b) system
c) java/system
d) /java/system

Answer: b
Explanation: obj.getName() returns the name of the file.
Output:
system

Join The Discussion