Questions tagged [static-binding]

Static binding is a method of dispatching methods in a object oriented programming languages: it basically means that the implementation of a method for a specific object is chosen at compile time and not a runtime.

57 questions
2
votes
3 answers

Why this static binding doesn't work as i would expect?

I have a question about how this program selects the method. Code(constructors aside): class Father { int x; .. public int m(Father f) { return (f.x - this.x); } } class Son extends Father { int y; ... public int…
2
votes
1 answer

Xamarin's new way of performing OnPlatform StaticResource binding

Previously I was able to do something like this Now that, that syntax is deprecated, I'm trying to do this:
Null Reference
  • 11,260
  • 40
  • 107
  • 184
2
votes
2 answers

C++ Static & Dynamic Binding behaviour

I understand the difference between static and dynamic binding in the sense that method calls are determined at compile time for static binding - whereas method calls are determined at run time for dynamic binding. One thing I don't get is why you…
2
votes
1 answer

Is there a template that can generate static / dynamically bound versions of a class?

I'm working on some library code, and I want users to be able to take advantage of static binding if they are able to. If they are unable to instantiate a class at compile time, I want there to be a dynamic version of the class, so that it can be…
bfair
  • 1,101
  • 7
  • 16
2
votes
2 answers

Java static and dynamic binding, upcast, overloading mixed together

Let's say that we have the following code class TestEqual{ public boolean equals(TestEqual other ) { System.out.println( "In equals from TestEqual" ); return false; } public static void main( String [] args ) { Object t1 = new…
Silent Control
  • 614
  • 10
  • 22
2
votes
2 answers

how to use an static var from child class in its parent class with an static method

I want to get the value of the static var that was redeclared in the subclass : class A { private static $echo_var = 'PARENT_ECHO' ; public static function e() { return '$echo_var = ' . self::$echo_var ; } …
Mottenmann
  • 413
  • 1
  • 4
  • 12
2
votes
2 answers

What are static and dynamic binding in C (strictly C,not C++)?

I had initial apprehensions about posting this question lest it be a duplicate.But even after googling with many keywords,I couldn't find any link on StackOverflow that explains static and dynamic binding for C.There are questions and answers for…
Rüppell's Vulture
  • 3,583
  • 7
  • 35
  • 49
1
vote
1 answer

PHP sibling classes static binding

When autoloading in multiple classes that extend the same parent, they seem to overwrite each others static variables. Using the code below, if the $staticvar is only defined in the parent Controller class then Foo::$staticvar is overwritten by the…
1
vote
2 answers

Binding type for a non-overriden virtual function

Consider the case where a virtual function in base class is not overriden in the derived class. Then using a base class pointer to a derived class objectthe virtual function is invoked. I understand that the function invocation will be…
1
vote
3 answers

In java, if a method NOT inherited by any subclass is called, whether dynamic binding or static binding is used?

In java, if a method NOT inherited by any subclass is called, whether dynamic binding or static binding is used? I know it won't make any difference to the output in this particular case, but just wanted know this.
user966892
1
vote
2 answers

static binding with new operator c++

i want to be sure if i understand that corectly. If i have something like that: Base* wsk = new Derived and if i've done that with static-binding than wsk is type of Base, but Derived type object is still created? And wsk is pointing to that…
Tojmak
  • 155
  • 1
  • 7
1
vote
1 answer

Can you "dynamically bind" overloaded methods?

public class ConstructorOverloading { static class A{ final String msg; public A(Object o){ this.msg = "via object"; } public A(Integer i){ this.msg = "via integer"; } } …
1
vote
0 answers

Static binding in Java

I thought that the output of the following code would have been ABB, instead it is AAB, why does java do static binding here? public class A {} public class B extends A {} public class C { void f(A x) { System.out.println("A"); } void f(B x)…
Riccardo
  • 111
  • 3
1
vote
4 answers

Java: static- vs. dynamic binding (again)

i've read a lot of blogs, tutorials & co but i don't get something about the dynamic binding in java. When i create the object called "myspecialcar" it's creates an object from the class "car" as type of the class vehicle as a dynamic binding right?…
CLNRMN
  • 1,409
  • 9
  • 23
1
vote
2 answers

Java method selection with overloading and overriding

I am having hard time to understand some principles about overriding and overloading. public class Figure{ public void stampa(Figure f){ System.out.println("Figure"); } } public class Square extends Figure{ public void…