Java vs. C#

default Modifier


Java
 
class A
{
    int x;
    static void F(B b) {
        b.x = 1;    // Ok
    }
}
class B extends A
{
    static void F(B b) {
        b.x = 1;    // Ok
    }
}

class A {...} public class B { A F() {...} A G() {...} public A H() {...}//ok }

C#
 
class A
{
    int x;
    static void F(B b) {
        b.x = 1;    // Ok
    }
}
class B: A
{
    static void F(B b) {
        b.x = 1; // Error, x not accessible
    }
}

class A {...} public class B { A F() {...} internal A G() {...} public A H() {...}//error } the H method in B results in a compile-time error because the return type A is not at least as accessible as the method.