The onBackPressed() method is called without me having to write onBackPressed(); inside the onCreate() method. I know the method works because when I comment it out, its effect is removed (which is to exit the program from the MainActivity even if other activities are called). 
Also, if I input onBackPressed(); into the MainActivity, then it will not work. I'm really confused why onBackPressed() method works without me having to call the method. Sorry if I did not phrase the question correctly, I hope I did! And thanks in advance!!
public class MainActivity extends ActionBarActivity{
private Button button;
private Button button2;
private ImageView im;
private ImageView im2;
private boolean doubleBackToExitPressedOnce = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);
 }
@Override
public void onBackPressed(){
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}
public void changeColor() {
    button = (Button) findViewById(R.id.button);
    im = (ImageView) findViewById(R.id.imageView2);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            im.setBackgroundColor(Color.rgb(255,255,255));
        }
    });
  }
 }
 
     
     
     
    