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
Related Posts
The #elif directive cannot appear after the preprocessor #else directive.
Conditional inclusion can be used for ___________
In a conditional inclusion, if the condition that comes after the if is true, then what will happen during compilation?
What will be the output of the following C code?
#include < stdio.h >
#define COLD
int main()
{
#ifdef COLD
printf(“COLD\t”);
#undef COLD
#endif
#ifdef COLD
printf(“HOT\t”);
#endif
}The “else if” in conditional inclusion is written by?
What will be the output of the following C code?
#include < stdio.h >
#define SYSTEM 20
int main()
{
int a = 20;
#if SYSTEM == a
printf(“HELLO “);
#endif
#if SYSTEM == 20
printf(“WORLD\n”);
#endif
}What is the advantage of #define over const?
Join The Discussion