-
What is the output of this program?
package pack;
class dis
{
int p;
void output()
{
if (p > 1)
System.out.print(p + " ");
}
}
public class packages_Example
{
public static void main(String args[])
{
dis[] array=new dis[5];
for(int k=0; k<5; k++)
array[k]=new dis();
array[0].p = 5;
array[1].p = 7;
array[2].p = 9;
for (int k = 0; k < 5; ++k)
array[k].output();
}
}
Note : packages_Example.class file is in directory pack;
-
- 7 9
- 5 7 9
- 7 5 9
- 9 7 5
- None of these
Correct Option: B
5 7 9