1.

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;

A. 7 9
B. 5 7 9
C. 7 5 9
D. 9 7 5
E. None of these
Answer» C. 7 5 9


Discussion

No Comment Found

Related MCQs