Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Q 2 of 5 The Activity Lifecycle (Android)

Q) The onCreate() method in Activity sets a variable named 'otherString'. Replace the word ‘UNKNOWN’ with the correct word (‘BEFORE’ or ‘AFTER’) to make the sentence for the 'aString' variable true.

I HAVE NO FREAKING CLUE with the code provided. I don't see a variable name 'otherString' at all. NONE is declared. So i'm not sure if i'm just miss understanding the question, or what. Also, I have watched the video 3x and see in no way how this question (as I am currently reading it) pertains to the video.


PS. this might have a tiny bit to do with that i'm extremely tired!

Thanks - Sleepless in Saint Louis

3 Answers

The question is a bit confusing. It took me a few minutes to understand its meaning.

Ok, In the quiz, it's asking you to create a String variable called otherString in the onCreate() method; then it wants you to update the text of aString that indicates if aString is placed before or after otherString in the method. The directions tell us the aString should be placed after otherString.

public void onCreate(...){
//add otherString 

String otherString;

//update the text in aString
aString = "This.... AFTER ... ";

TEACHER EDIT You don't need to declare the otherString variable as it is already declared and set in the Activity super class. I'll change the wording of the question, though. :smile:

Ben Jakuben could you look into this question? I too think it could be worded a little bit better.

thanks for the suggestion. i will try this this evening!



Thanks J. T. !!

THAT WAS EASY! Would have NEVER gotten that.

You're welcome. I'm glad you were able to get it!

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Sorry for the confusion everyone! You have to read it carefully to make sense of it, but I think I can definitely enhance the description and will tackle that shortly. This line: "The onCreate() method in Activity sets a variable named 'otherString'." indicates that the otherString variable is part of the Activity super class. As a variable in the super class, it means that it's also available in the subclass that we're working in. otherString gets set in the super class when super.onCreate() is called. Knowing that, you should be able to change UNKNOWN to BEFORE or AFTER by walking through how the code will execute.

Anyhow, thanks for the feedback, and keep on coding!

Thanks Ben Jakuben! I think the confusing part for me was the first sentence of the question. To me, the way its worded makes me feel that the variable is already declared when it wasn't. After getting thru, i now see what you were asking for.

Thanks for looking it to it! Love the videos!

haha I thought you had to use string concatenation and that the super variable had to be called. I thought that super var had BEFORE or AFTER in it.

I think it would be more straight-forward if the question asked:

Is aString set BEFORE or AFTER the 'otherString' variable (otherString is in the Super Class). Please replace UNKNOWN on line 19 with your answer.

If they get the answer wrong, then you can inform that about how inheritance works. Just a thought.