Register on the forum now to remove ALL ads + popups + get access to tons of hidden content for members only!

Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > Java

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 05-29-2018, 07:16 AM   #1
ajaxdns
Registered User
 
Join Date: Apr 2018
Posts: 413
What is difference between static (class) method and instance method?

static or class method instance method
1)A method i.e. declared as static is known as static method. A method i.e. not declared as static is known as instance method.
2)Object is not required to call static method. Object is required to call instance methods.
3)Non-static (instance) members cannot be accessed in static context (static method, static block and static nested class) directly. static and non-static variables both can be accessed in instance methods.
4)For example: public static int cube(int n){ return n*n*n;} For example: public void msg(){...}.
ajaxdns is offline   Reply With Quote

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is static method? ajaxdns Java 0 05-29-2018 07:13 AM
What is difference between static (class) method and instance method? sunled Java 0 05-23-2018 12:02 AM
What is difference between static (class) method and instance method? sunled Java 0 04-12-2018 09:46 PM
What is difference between static (class) method and instance method? sunled Java 0 03-26-2018 10:33 PM
What is difference between static (class) method and instance method? sunled Graphic Design 4 12-10-2017 05:26 AM


All times are GMT -7. The time now is 11:28 AM.


Powered by vBulletin Copyright © 2013 vBulletin Solutions, Inc.