Win Surprise Gifts!!!
Top 5 Contributors of the Month
Post New Question
Subscribe to Interview Questions
Relationship between Class and Object?
Posted By :
Posted Date :
September 18, 2011
Class and object look very similar.
Class is a definition,while object is the instance of the class created.
Class is a blueprint while objects are actual objects exsisting in real world
You can also find related Interview Question to
Relationship between Class and Object?
How can I look up a parent class method or property of any System-level object?
Use the Class View window, accessed from the standard toolbar by clicking View | Class View.
Which method is used to serialize an object into an XML document from Xmlserializer class?
The "Serialize" method is the first step of serialize process and used to create an XML document
Tell any one method use in form with out use of Class Object
This is the progam using inheritence, what is the order of calling constructors and what is the output?
Public Class ConstructorEx
Public Class Class1
Dim a As Integer
a = 1
Console.WriteLine("a in initialized in Class1")
Public Class Class2
Dim b As Integer
b = 1
Console.WriteLine("b in initialized in Class2")
Public Class Class3
Dim c As Integer
c = 1
Console.WriteLine("c in initialized in Class2")
Shared Sub main()
'Creation of the object of type Class3
Dim c As New Class3()
In this example creation of the object of type class3 calls the Class3 constructor and that constructor calls Class2 Constructor Class2 Calls Class1 Constructor.So first Class1 constructor will execute and then control will be trasfered to class2 constructor,After executing the class2 constructor the control will be treansfered to Class3 constructor.
| 'First it will execute <-----|
| End Sub |
| Class2 |
| 'Second it will execute<-------|
| End Sub |
| Class3 |
'Third this will executes<-----|
Means In the Creation of the object of type C, First Class1 Constuctor initializes the data, then class2 then class3.
So output of this program is
a in initialized in Class1
b in initialized in Class2
c in initialized in Class3
Name the class which remote object has to inherit ?
What is the difference between class and object?
Classes describe the structure of objects, while objects are usable instances of classes. Each instance is an exact yet distinct copy of its class. Because an object is an instance of a class, the act of creating an object is called instantiation.
Usually, changing the data in one object does not change the data in any other object.
Which namespace is the base class for .net Class library?
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.
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.
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.
What event class gives a description about the type of a mousebutton pressed ?
How can you prevent a class from inheriting?
Using Sealed keyword
What is the difference between interface and abstract class ?
a class may inherit several interfaces, a class may inherit only one abstract class
What is the default access specifier for a top level class which are not nested into other class?
Quick Links For Interview Questions Categories:
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
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
Terms of Service
Tell A Friend