Page 1 of 1

About Question enthuware.ocpjp.v7.2.1443 :

Posted: Thu Jul 16, 2015 4:53 am
by colmkav
Is Button on the syllabus? There is no mention of addActionListener in the OCA/OCP SE7 Programmer I & II study guide book I am using. I realise that the crux of the question is about the nonstatic variable not being availanle within main method but it is confusing when reading the question. Will they do this kind of thing in the exam?

Re: About Question enthuware.ocpjp.v7.2.1443 :

Posted: Thu Jul 16, 2015 6:52 am
by admin
If you are getting confused just because of the use of Button or ActionListener classes then you need to get used to such style. You will see questions with nonsensical names such as Foo and Bar but you will also see questions with real class names. In both the cases, you need to worry only about OCAJP related concepts. The questions will not require you to know about those classes.

Re: About Question enthuware.ocpjp.v7.2.1443 :

Posted: Tue Jul 28, 2015 10:14 am
by gk_javauser
Is there a way to generalize how classes with different modifiers within different modifiers behave?

For instance:

Non-static class within static class, which in turn contains a static class and non-static class as well as static and non-static methods.

Basically I am interested in knowing how these things behave if class declarations go deeper than one level (if possible).

Thanks!

Re: About Question enthuware.ocpjp.v7.2.1443 :

Posted: Tue Jul 28, 2015 10:30 am
by admin
You might want to try out a couple of examples and it will be clear. There is nothing much complicated there.

Re: About Question enthuware.ocpjp.v7.2.1443 :

Posted: Thu Sep 21, 2017 7:39 am
by horst1a
Sorry, might be considered a silly question. Where is the inner class here , mentioned in the explanation ?

Re: About Question enthuware.ocpjp.v7.2.1443 :

Posted: Thu Sep 21, 2017 7:55 am
by admin
This statement in the code:

Code: Select all

new ActionListener()
                  {
                     public void actionPerformed(ActionEvent e)
                     {
                        System.out.println("Message is " +s);
                     }
                  }
creates an anonymous inner class that implements ActionListener. You should go through this tutorial to learn the basics of inner classes:
https://docs.oracle.com/javase/tutorial ... asses.html

HTH,
Paul.

Re: About Question enthuware.ocpjp.v7.2.1443 :

Posted: Fri Nov 10, 2017 12:14 pm
by ehsanc
What about this line:

t.add(b);

Should I know that Frame inherits this method? Is it safe to assume methods are inherited where they are not apparent in a class but the class extends another? I got the answer correct but only because I thought that class TestFrame has no method add()

Re: About Question enthuware.ocpjp.v7.2.1443 :

Posted: Fri Nov 10, 2017 9:36 pm
by admin
add is a valid method in Frame class. You should assume that everything that is not on the exam is valid and does not affect the answer. In this case, you should ignore the methods addActionListener and add. You will be able to get to the answer just by applying the concepts that are covered on the exam.