Quiz

Q1

You use principles of Inheritance when you create an Activity.

true false Yes, the Java class that you create should extend any Android API class which is also an Activity there by inheriting the top level Activity class.

You should use the annotation @override otherwise the method really does not override

true false Annotation is not required for overriding. If the child has a method signature which can override the parent, then it does override even without an annotation. However we use annotation to ensure that you truly are overriding the parent method. If this annotation is present and if you made a mistake in defining the child method signature which does not really override any method from parent, then a compile error is shown. So having annotations will help you write better code with less errors.

The widgets that are defined in the layout xml file will be used to create objects of that type in JVM when the Activity is instantiated by the Android OS.

true false Yes, that is correct. In the onCreate method of the Activity, you get to set the layout xml file using setContentView. Using this information, the required widget objects are created which can be retrieved using the findViewById method of the Activity.

The Activity object is alive in memory when you are interactiving with the Activity.

true false Yes, that is correct.

You can use instance variables in the Activity class to hold any state information of the Activity object

true false Yes, that is correct. Remember if you need the state to be held between button clicks for example, you need to have instance variables and not local variables inside the method.

results matching ""

    No results matching ""