About Question enthuware.ocpjp.v7.2.1443 :
Moderator: admin
-
- Posts: 21
- Joined: Thu Jul 16, 2015 4:22 am
- Contact:
About Question enthuware.ocpjp.v7.2.1443 :
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?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1443 :
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.
If you like our products and services, please help us by posting your review here.
-
- Posts: 9
- Joined: Sun Jul 19, 2015 6:31 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1443 :
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!
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!
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1443 :
You might want to try out a couple of examples and it will be clear. There is nothing much complicated there.
If you like our products and services, please help us by posting your review here.
-
- Posts: 37
- Joined: Mon Jun 12, 2017 2:16 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1443 :
Sorry, might be considered a silly question. Where is the inner class here , mentioned in the explanation ?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1443 :
This statement in the code:
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.
Code: Select all
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.out.println("Message is " +s);
}
}
https://docs.oracle.com/javase/tutorial ... asses.html
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Fri Nov 10, 2017 12:06 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1443 :
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()
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()
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1443 :
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.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 113 guests