:: Home

  login:         
  passwords:  

OOP Interview Questions and answers [Part 4]

The General Oop Interview Questions consists the most frequently asked questions in Oop. This list of 100+ questions guage your familiarity with the Oop . The q&a have been collected over a period of time from various blogs, forums and other sites

4. OOP Interview Questions and FAQs [Part 4]

    4.1 Describe what an Interface is and how it?s different from a Class
    4.2 In which Scenario you will go for Interface or Abstract Class?
    4.3 In which cases you use override and new base?
    4.4 Can we call a base class method without creating instance?
    4.5 What is meant by files?
    4.6 What is a subclass?
    4.7 What is a superclass?
    4.8 What is a constructor?
    4.9 What is a destructor?
    4.10 What is meant by Binding?
    4.11 What is meant by static binding?
    4.12 What is meant by Dynamic binding?
    4.13 Define Modularity?
    4.14 What is meant by Persistence?
    4.15 What is colloboration?
    4.16 Limitations and Restrictions of Interface?
    4.17 What is a static class?
    4.18 What is static member of class?
    4.19 What is the use of parameter array?
    4.20 What is the difference between reference parameter and output parameter?

4.1 Describe what an Interface is and how it's different from a Class

In Interface,we cannot specify any definition inside but where as class we can.


4.2 In which Scenario you will go for Interface or Abstract Class?

Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes. Even though class inheritance allows your classes to inherit implementation from a base class, it also forces you to make most of your design decisions when the class is first published. Abstract classes are useful when creating components because they allow you specify an invariant level of functionality in some methods, but leave the implementation of other methods until a specific implementation of that class is needed. They also version well, because if additional functionality is needed in derived classes, it can be added to the base class without breaking code.


4.3 In which cases you use override and new base?

Use the new modifier to explicitly hide a member inherited from a base class. To hide an inherited member, declare it in the derived class using the same name, and modify it with the new modifier.


4.4 Can we call a base class method without creating instance?

You can call it using derived class object or in a derived class member function depending upon base class fun's access spicier and inheritance specified.


4.5 what is meant by files?

A file is a collection of records and a record is a collection of fields. by keeping your data on file u can save permanently. that is a file is saved on disk memory


4.6 What is a subclass?

Subclass is a class that inherits from one or more classes


4.7 What is a superclass?

superclass is a class from which another class inherits.


4.8 What is a constructor?

Constructor is an operation that creates an object and/or initialises its state.


4.9 What is a destructor?

Destructor is an operation that frees the state of an object and/or destroys the object itself. In Java, there is no concept of destructors. Its taken care by the JVM.


4.10 What is meant by Binding?

Binding denotes association of a name with a class.


4.11 What is meant by static binding?

Static binding is a binding in which the class association is made during compile time. This is also called as Early binding.


4.12 What is meant by Dynamic binding?

Dynamic binding is a binding in which the class association is not made until the object is created at execution time. It is also called as Late binding.


4.13 Define Modularity?

Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.


4.14 What is meant by Persistence?

Persistence is the property of an object by which its existence transcends space and time.


4.15 What is colloboration?

Colloboration is a process whereby several objects cooperate to provide some higher level behaviour.


4.16 Limitations and Restrictions of Interface?

The essential idea to remember is that an interface never contains any implementation. The following restrictions and imitations are natural consequences of this: You're not allowed any fields in an interface, not even static ones. A field is an implementation of an object attribute. You're not allowed any constructors in an interface. A constructor contains the statements used to initialize the fields in an object, and an interface does not contain any fields! You're not allowed a destructor in an interface. A destructor contains the statements used to destroy an object instance. You cannot supply an access modifier. All methods in an interface are implicitly public. You cannot nest any types (enums, structs, classes, interfaces, or delegates) inside an interface.


4.17 What is a static class?

We can declare a static class. We use static class when there is no data or behavior in the class that depends on object identity. A static class can have only static members. We can not create instances of a static class using the new keyword. .NET Framework common language runtime (CLR) loads Static classes automatically when the program or namespace containing the class is loaded. Here are some more features of static class: • Static classes only contain static members. • Static classes can not be instantiated. They cannot contain Instance Constructors • Static classes are sealed.


4.18 What is static member of class?

A static member belongs to the class rather than to the instances of the class. In C# data fields, member functions, properties and events can be declared static. When any instances of the class are created, they cannot be used to access the static member. To access a static class member, use the name of the class instead of an instance variable Static methods and Static properties can only access static fields and static events. Like: int i = Car.GetWheels; Here Car is class name and GetWheels is static property. Static members are often used to represent data or calculations that do not change in response to object state.


4.19 What is the use of parameter array?

A parameter array enables a many-to-one relationship: many arguments can be represented by a single parameter array. In other words, parameter arrays enable variable length argument lists. A parameter array is declared with a params modifier in C#. There can be only one parameter array for a given method, and it must always be the last parameter specified. The type of a parameter array is always a single dimensional array type. A caller can either pass a single argument of this array type, or any number of arguments of the element type of this array type.


4.20 What is the difference between reference parameter and output parameter?

Modifications of a reference parameter and output parameter impact the corresponding argument. So an output parameter is similar to a reference parameter, except that the initial value of the caller-provided argument is unimportant.

Copyright 2007, Megasolutions Ltd