Online Examination System for all learner!!! coming soon..

JAVA : Classes and Methods


Classes might contain only code or data but may also contain both. A class is declared by keyword class and it can be complex in nature.
Diagram of Classes and Methods
Syntax:
Class classname
{
          Type instance-variable a;
          Type instance-variable b;
          .
          .
          .
          Type instance-variable n;
}
Type method a (parameter-list)
{
          //body of method
}
Type methodname a (parameter-list)
{
          //body of method
          .
          .
}
Classes are also called the box which defines variable- width, height and depth.
Example
Class box
{
          Double width;
          Double height;
          Double depth;
}
Class that implements stack of data and integer.
Example
Class stack
{
          Int stk [] = new int [10];
          Stack ()
          Tos=-1
}
Void push (int item) {
          If (tos==9)
          System.out.println (‘it’s full”);
          Else
          Stk [++tos] = item;
}
Int pop ()
{       
          if (tos<0)
          {
                   System.out.println (“stack underflow”);
                   Return 0;
          }
          else
                   Return stk[tos—];
}
}

C Programming Online Test 1

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...