in java, inheritance works like following ..
public class Test1 extends Test{
@Override
public String getName() {
return super.getName();
}
public static void main(String[] args) {
Test1 test1=new Test1();
System.out.println(test1.getName());
}
}
public class Test{
String name = "Happy";
int id=64;
public String getName(){
return name;
};
public int getId(){
return id;
}
}
but in android
public class MainActivity extends AppCompatActivity {
String TAG = "androiod";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
how setContentView is used in android .its declared in its parent class as onCreate is defined in its main class. onCreate and setContentView are methods of the same class(referring to Appcompactactivity class). on create is overridden, I understand. but how setContentView is used directly. I mean if it's inherited from appCompact.. class .. in a child we can override parent class methods as we did to onCreate... but how setContentView is used directly neither we are overriding nor we are creating any object of Main activity class