About Question enthuware.ocpjp.v7.2.1443 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
colmkav
Posts: 21
Joined: Thu Jul 16, 2015 4:22 am
Contact:

About Question enthuware.ocpjp.v7.2.1443 :

Post 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?

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

gk_javauser
Posts: 9
Joined: Sun Jul 19, 2015 6:31 pm
Contact:

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

Post 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!

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

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.

horst1a
Posts: 37
Joined: Mon Jun 12, 2017 2:16 am
Contact:

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

Post by horst1a »

Sorry, might be considered a silly question. Where is the inner class here , mentioned in the explanation ?

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

ehsanc
Posts: 1
Joined: Fri Nov 10, 2017 12:06 pm
Contact:

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

Post 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()

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 37 guests