answermid

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author sohel
 */
public class star
{
 public static void main(String args[])
         {
          for(int i=0; i<=5 ;i++)
            {
              for(int j=0; j < i; j++)
              {
                  System.out.print(" *");
          
              }
              System.out.println("");
           }
       }
}







/**
 *
 * @author sohel
 */
import java.util.Scanner;
public class factorial
{
    public static void main(String argd[])
    {
        Scanner input=new Scanner(System.in);
        int x,i;
        int fact=1;
        System.out.println("Enter a valu: ");
        x=input.nextInt();
        for(i=1; i<=x; i++) {
            fact *= i;
        }
        System.out.printf("%d ",fact);
    }
}
Publisher: notnow - 10:16 PM


Definition of OOP:
OOP uses objects as its fundamental building blocks. Each object is an instance of some class. Classes allow the mechanism of data abstraction for creating new data types. Inheritance allows building of new classes from existing classes. Hence if any of these elements are missing in a program we cannot consider that program as objected oriented program.

Object-oriented programming is a programming methodology that associates data structures with a set of operators which act upon it. In OOP’s terminology an instance of such an entity is known as an object. It gives importance to relationships between objects rather than implementation details. Hiding the implementation details within an object results in the user being more concerned with an objects relationship to the rest of the system, than the implementation of the object’s behavior.
Publisher: notnow - 1:44 AM

java1

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".
Publisher: notnow - 6:49 PM