Filled Under:

java1

Share
Midterm Examination

 Question layout


                                        PART A
No.1                                  ***********************




class
{
   void show()
}
 system.out.print(show(5));
{
 private int show(int x)
{
        for(int i=0;i<50;i++)
           if(i%2==0)continue;
            else x=i;
    return x;
}
public static void main(string arg[])
{
 test xyz=new test();
xyz.show();
}
 
}




*******************************************************

No.2


class worldcup
{
       public void country(string name, int x)

{
           
        if(x==0)
           system.out.print(name= "Defeated");
        else
              system.out.print(name= "Wins");
}

}

   class schedule
{
  public int roster(String name, int x)
{
       worldcup abc=new worldcup();
       abc.country(name,x);
       return x;
}

}

  class home extends schedule
{
   home()
   {
              schedule mno=new schedule();
     if(mno.roster("Argentina",0)==0)
      system.out.print("\nIt is TRUE");
       else
       system.out.print("\n it is FALSE");
}
public static void main(String arg[])
{
 home xyz=new home();

}

}



*********************************************************

No.3


class test
{
         test()
{
   system.out.print("In show");
}

protected void test(int x)
{
 system.out.print("In show x");
}

public void test(String x)
{
   system.out.print("In show String x");
}

}

class testy extends test

{

   void testy()
{
    test xyz=new test();
}
public static void main(String arg[])
{

   testy xyz=new testy();
}

}

*************************************************************







                                                PART B
                                         *************************






No.4




write a java code to show the follwing table of "stars" . here the number of line is given by user :


input:5          output:    *
                            **
                            ***
                            ****
                            *****







No.5


define polymorphism with example.




No.6



what is multilevel inheritance? give example.




No.7



write a java code to identify an inputted number is "ODD" or EVEN".

0 মন্তব্য(সমূহ):

Post a Comment