.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

Similarities between Class and Struts

Posted By :Karthikeyan Anbarasan     Posted Date :May 30, 2011    Points :40   Category :.NET Framework 
Both are user defined types.

· Both of them can have constructor without parameter and with parameter.
· Both can have delegates and events.
· Both can have methods, properties , fields, constants , enumerations, events.

You can also find related Interview Question to Similarities between Class and Struts  below: 

Difference between Class and Struts


Class is a reference type
Struct is a value type

Class supports inheritance
Struct will not support inheritance

Class variables are stored on Heap
Struct variables are stored on Stack

Class can have destructor
Struct will not have destructor

Boxing a class object creates reference to same object
Boxing a strut object will create a copy in diff type

All the members of Class are private by default
All the members of struct are public by default

Class is well suited for Data hiding
Struts are not suited for Data hiding


What is the difference between a Struct and a Class?

The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color. Although it is possible to represent a point as a class, a struct is more efficient in some scenarios. For example, if you declare an array of 1000 Point objects, you will allocate additional memory for referencing each object. In this case, the struct is less expensive.

When you create a struct object using the new operator, it gets created and the appropriate constructor is called. Unlike classes, structs can be instantiated without using the new operator. If you do not use new, the fields will remain unassigned and the object cannot be used until all of the fields are initialized.

It is an error to declare a default (parameterless) constructor for a struct. A default constructor is always provided to initialize the struct members to their default values.

It is an error to initialize an instance field in a struct.

There is no inheritance for structs as there is for classes. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Structs, however, inherit from the base class Object. A struct can implement interfaces, and it does that exactly as classes do.

A struct is a value type, while a class is a reference type. (More...)

Can we call a base class method without creating instance?

Its possible If its a static method.

Its possible by inheriting from that class also.

Its possible from derived classes using base keyword. (More...)

What is Private Constructor? and it's use? Can you create instance of a class which has Private Constructor?

When a class declares only private instance constructors, it is not possible for classes outside the program to derive from the class or to directly create instances of it. (Except Nested classes)
Make a constructor private if:

1) You want it to be available only to the class itself. For example, you might have a special constructor used only in the implementation of your class' Clone method.

2) You do not want instances of your component to be created. For example, you may have a class containing nothing but Shared utility functions, and no instance data. Creating instances of the class would waste memory. (More...)

What is the difference between interface and abstract class ?

a class may inherit several interfaces, a class may inherit only one abstract class (More...)

Differentiate between a template class and class template.

Template class:
A generic definition or a parameterized class not instantiated until the client provides the needed information. It's jargon for plain templates.

Class template:
A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It's jargon for plain classes. (More...)

What is an adaptor class or Wrapper class?

A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non- object- oriented implementation. (More...)

What is class invariant?

A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, and they must be preserved under all operations of the class. In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class. (More...)

What are the conditions that have to be met for a condition to be an invariant of the class?

1.The condition should hold at the end of every constructor.
2.The condition should hold at the end of every mutator (non-const) operation. (More...)

What is a node class?

. A node class is a class that,
. Relies on the base class for services and implementation,
. Provides a wider interface to te users than its base class,
. Relies primarily on virtual functions in its public interface
. Depends on all its direct and indirect base class
. Can be understood only in the context of the base class
. Can be used as base for further derivation
. Can be used to create objects.

A node class is a class that has added new services or functionality beyond the services inherited from its base class. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend