Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-12-2010
Member
 
Join Date: Dec 2010
Posts: 59
static methods in object oriented programming

I am a student of Third year , I have subjects like SQL, ERP , implementation , Supply chain management and Customer relationship management and programming languages like Core JAVA and C# in my third year, although my third year has just began but still it is one of the important year of my career , I have my unit test on my head the upcoming week, however one concept in my C# subject is not clear and and that is the static data members, it was covered there in the Core Java last semester , so it will be of much more help if you could provide of necessary information. I would appreciate if any programmer or developer replies .
Reply With Quote
  #2  
Old 25-12-2010
Member
 
Join Date: May 2009
Posts: 503
Re: static methods in object oriented programming

Static data members are those data members which are referred without the reference of any object. The scope of any static data member is not restricted to any particular object. Like a normal variable , which is accessed with the help of a dot operator , it does not happen at all with these static data member, they are directly referred or called with the class name.
Reply With Quote
  #3  
Old 25-12-2010
Member
 
Join Date: May 2009
Posts: 533
Re: static methods in object oriented programming

A C# class can enclose both static and non-static data members. When we initiate a member and make the use of the keyword static, it produces a static member. This type of data member does not belong to any object but rather belong to the class Therefore static data members are also known as class data members and non-static data members are called as instance members.Bear in mind that indexers in C# can't declared as static and if you do not mention the keyword static then it is by default non static.
Reply With Quote
  #4  
Old 25-12-2010
Member
 
Join Date: May 2009
Posts: 525
Re: static methods in object oriented programming

The standard way to interact with a class, is to make a new object of the class, and then operate on the resulting object. In the majority cases, this is what basic constructs are all about - the capacity to instantiate more than one copy of the that class and then utilize them in a different way. However, in a few cases, you may like to have a class which you may utilize without creating any object . For example, you will have a class with a identifier that in most cases remains the same, it does not matter at all how it is being used and where it is being used . This is known a static data member. static because it remains the same.
Reply With Quote
  #5  
Old 25-12-2010
Member
 
Join Date: Apr 2009
Posts: 567
Re: static methods in object oriented programming

Whenever any object of an class is created with the new keyword , a new copy of that variable or member is allocated is time it the class is instantiated , and to access that data member you will have to take the reference of that object , but a static data member creates only one copy and only that copy is available to the whole code throughout, and if you want to access that data member you will have to access it with the class name.
Reply With Quote
  #6  
Old 07-01-2011
Member
 
Join Date: May 2009
Posts: 525
Re: static methods in object oriented programming

The static member functions do not have an object scope and they do not possess any sort of control over 'this' pointer of the class. When a function is declared as static that is a static method of that class creates only one copy , that is that function or method itself throughout the whole program The major practice of static method is when the programmer requires to have a method which is available even when the class?s object is not created .


Code:
static return _type method_name() 
//Static method defined with static keyword
{ 
statement1; 
statement2; 
//Statements for execution inside static method
.......... 
.......... 
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "static methods in object oriented programming"
Thread Thread Starter Forum Replies Last Post
Object oriented programming with java cloud101 Software Development 2 22-02-2012 01:11 AM
What are the different types of Object Oriented Programming Languages? fLUTE Software Development 4 11-07-2011 02:39 PM
what is message passing and other terms in Object oriented programming languages? Palnila Software Development 3 08-01-2011 06:23 AM
Scope of Object or variable in Object oriented Programming Languages Dfrim Software Development 3 08-01-2011 06:20 AM
The OOP Object Oriented programming Concept & its principle? Bhavya Software Development 3 25-02-2009 09:16 PM


All times are GMT +5.5. The time now is 05:20 AM.