Thursday, September 24, 2015

Multilevel Inheritance and Function Overriding in Java

package oop;
public class Oop {

    public static class A{
        void func(){
            System.out.println("Function of A");
        }
    void func1(){
            System.out.println("Function of A");
        }
    }
    public static class B extends A{
        void func(){
            System.out.println("Function of B");
        } 
    void func1(){
        super.func1();
            System.out.println("Function of B");
        }    
    }
    public static class C extends B{
        void func(){
            System.out.println("Function of C");
        }        
    void  func1(){
        super.func1();
            System.out.println("Function of C");
        }
    }
    public static void main(String[] args) {
     
     
        C obj4=new C();
        obj4.func();
        obj4.func1();
    }
    }


Sunday, September 13, 2015

Interface /Abstract Classes in C++

An interface describes the behavior or capabilities of a C++ class without committing to a particular implementation of that class.
The C++ interfaces are implemented using abstract classes and these abstract classes should not be confused with data abstraction which is a concept of keeping implementation details separate from associated data.
A class is made abstract by declaring at least one of its functions as pure virtual function. A pure virtual function is specified by placing "= 0" in its declaration as follows:



#include <iostream.h>

class Shape

{

public:

// pure virtual function providing interface framework.

virtual int getArea() = 0;

void setWidth(int w)

{

width = w;

}

void setHeight(int h)

{

height = h;

}

protected:

int width;

int height;

};



class Rectangle: public Shape

{

public:

int getArea()

{

return (width * height);

}

};

class Triangle: public Shape

{

public:

int getArea()

{

return (width * height)/2;

}

};



int main(void){

Rectangle Rect;

Triangle Tri;

Rect.setWidth(5);

Rect.setHeight(7);

cout << "Total Rectangle area: " << Rect.getArea() << endl;

Tri.setWidth(5);

Tri.setHeight(7);

cout << "Total Triangle area: " << Tri.getArea() << endl;

return 0;

}

Interfaces in C#

An interface is defined as a syntactical contract that all the classes inheriting the interface should follow. The interface defines the 'what'part of the syntactical contract and the deriving classes define the 'how'part of the syntactical contract.
Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members. It often helps in providing a standard structure that the deriving classes would follow.
Abstract classes to some extent serve the same purpose, however, they are mostly used when only few methods are to be declared by the base class and the deriving class implements the functionalities.



using System;
namespace ArrayApplication
{
    public interface person{
         void name(string n);
         void age(int a );
         void clas(int c);
    }
   
    public class usman : person{
    public  void name(string n){
        Console.WriteLine("Usman name= "+n);
    }
    public void age(int a){
        Console.WriteLine("Usman age= "+a);
    }
    public void clas(int c){
        Console.WriteLine("Usman class= "+c);
    }
    }
   
    public class usama : person{
    public void name(string n){
        Console.WriteLine("Usman name= "+n);
    }
    public void age(int a){
        Console.WriteLine("Usman class= "+a);
    }
    public void clas(int c){
        Console.WriteLine("Usman class= "+c);
    }  
    }
   
   public class test
   {
       public static void Main(String[] args){
           usama obj=new usama();
           obj.name("Usama hussain");
           obj.age(20);
           obj.clas(10);
         
           usman obj1=new usman();
           obj1.name("Usman Siddique");
           obj1.age(21);
           obj1.clas(09);
       }
   }
}

=========================================
using System;
namespace ArrayApplication
{
    public interface abc{
         void fun();
              }

   public class MyArray : abc
   {
                                                         public void fun(){
                                                        Console.WriteLine("this is defination of interface fun");
                                                       }
                                                       static void Main(string[] args){
                                                       MyArray obj=new MyArray();
                                                      obj.fun();
                                                      }    }    }
       
   

Inheritance in C#

using System;
namespace ArrayApplication
{
    class abc{
        public void fun(){
            Console.WriteLine("This is A function of base class abc");
        }
    }
   class MyArray : abc  
   {
       static void Main(string[] args)
      {
         MyArray obj=new MyArray();
         obj.fun();
      }
   }
}

Argument / Parameter passing in C# Functions

using System;
namespace ArrayApplication
{
   class MyArray
   {
       public MyArray(){
           Console.WriteLine("Construtor Invoke");
       }
       public void myfun(int a){
           Console.WriteLine("User Pass the value = "+a);
       }
      static void Main(string[] args)
      {
         MyArray obj=new MyArray();
         obj.myfun(20);
       
      }
   }
}

Functions in C#

using System;
namespace ArrayApplication
{
   class MyArray
   {
       public MyArray(){
           Console.WriteLine("Construtor Invoke");
       }
       public void myfun(){
           Console.WriteLine("Its a funtion under My Array class");
       }
      static void Main(string[] args)
      {
         MyArray obj=new MyArray();
         obj.myfun();
       
      }
   }
}

Object Creation and Constructor in C#

using System;
namespace ArrayApplication
{
   class MyArray
   {
       public MyArray(){
           Console.WriteLine("Construtor Invoke");
       }
      static void Main(string[] args)
      {
         MyArray obj=new MyArray();
       
      }
   }
}

Create a table in C#

using System;
namespace ArrayApplication
{
   class MyArray
   {
      static void Main(string[] args)
      {
         int no,i;
         no=5;
         for(i=1;i<=10;i++){
             Console.WriteLine(no+" * "+i+" = "+no*i);
         }
      }
   }
}

Hello World in C#

using System;
namespace ArrayApplication
{
   class MyArray
   {
      static void Main(string[] args)
      {
         Console.WriteLine("Helo World...Its my First C# Program");
      }
   }
}


Saturday, September 12, 2015

Constructor and Object in Java

Different Types Of Constructor in Java ... Default Constructor,Pramiterized Constructor ,,Over-loaded Constructor:-

package oop;
public class Oop {

    public int ID;
    public String name;
    public char bloodgroup;
   
    Oop(){
        System.out.println("This is the Default Constructor");
    }
    Oop(int a){
        System.out.println("This is a prametrized Constructor No= "+a);
    }
    Oop(String a){
        System.out.println("This is an other Constructor name= "+a);
    }
   
    public static void main(String[] args) {
        Oop obj1=new Oop();
        Oop obj2=new Oop(2015);
        Oop obj3=new Oop("3rd Constructor");
       
        obj1.ID=34;
        obj1.name="usman";
        obj1.bloodgroup='a';
               
    }
}

=================================
package usman1;
public class Usman1 {
    int age;
    String name;
    public Usman1(int a,String b){
age=a;
name=b;
System.out.println("Name= "+name+" age= "+age);
    }
    public static void main(String[] args) {
     Usman1 obj=new Usman1(20,"Usman Siddique");
    }  
    }

Tuesday, September 8, 2015

5th Semester E-Books BSE-5

DLD (Digital Logic and Computer Design)  

by Morris Mano 4th edition .pdf


Click Here:-



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

OPERATING SYSTEM CONCEPTS 9th Edition .pdf

ABRAHAM SILBERSCHATZ
 Yale University
PETER BAER GALVIN
 Pluribus Networks 
GREG GAGNE 
Westminster College

Click Here:-