php hit counter

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
we can not call the non static methods from a sttic methods is it true statement??
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#2
Dear Student,

All static methods work alike and you are not right in sense that we call non static method in static method by providing it a reference to the belonging object.
e.g. look at following code:
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Main m1 = new Main();
m1.disp1();
NewClass.disp();
}
public void disp1(){
System.out.println("its a non static method");
}
}
public class NewClass {
public static void disp(){
System.out.println("its a static method");
NewClass n1 = new NewClass();
n1.disp1();
}
public void disp1(){
System.out.println("its a non static method");
}
}
Output:
run:
its a non static method
its a static method
its a non static method

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Messages In This Thread
we can not call the non static methods from a sttic methods is it true statement?? - by Vuhelper - 04-24-2011, 05:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How static class variables get initialized Vuhelper 0 909 06-09-2011, 09:56 PM
Last Post: Vuhelper
  what is the difference between Static method and the method we write in Clas saneha 1 4,852 04-28-2011, 09:12 PM
Last Post: Vuhelper
  Differentiate between static and nonstatic members in java 2011 saneha 1 2,562 04-27-2011, 11:03 PM
Last Post: Vuhelper
  between Get and Post methods saneha 1 2,740 04-24-2011, 10:45 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support