About Question enthuware.ocpjp.v7.2.1484 :

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

Moderator: admin

Post Reply
erbegu
Posts: 5
Joined: Thu Mar 06, 2014 9:29 am
Contact:

About Question enthuware.ocpjp.v7.2.1484 :

Post by erbegu »

Code: Select all

abstract class SomeClass {   public abstract void m1(); }
public class TestClass
{
  public static class StaticInnetClass { }  //option 1
  public SomeClass getSomeClass()
  {
      return new SomeClass()
         {
            public void m1() { }
         };
  }
}
Is this the way meant for extending from SomeClass? Without using "extends" anywhere?

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

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

Post by admin »

Yes, it is correct. It shows you various valid scenarios mentioned in the options.
If you like our products and services, please help us by posting your review here.

erbegu
Posts: 5
Joined: Thu Mar 06, 2014 9:29 am
Contact:

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

Post by erbegu »

Thank you!

vijayanand
Posts: 10
Joined: Fri Sep 26, 2014 8:40 am
Contact:

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

Post by vijayanand »

Is this the only way a class can extend an abstract class without using extend keyword?

if there is any other way, please suggest

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

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

Post by admin »

Yes, that is the only way.
If you like our products and services, please help us by posting your review here.

insider
Posts: 29
Joined: Wed Apr 17, 2013 9:22 am
Contact:

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

Post by insider »

Typo in "StaticInnetClass". Probably, should be "StaticInnerClass".

sohamdatey22
Posts: 28
Joined: Sun Sep 11, 2022 3:55 am
Contact:

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

Post by sohamdatey22 »

Anonymous inner classes can also be, instance members, and declared outside the method in class.
The question should denote that, which anonymous inner class we are referring here.

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

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

Post by admin »

Not sure which option are you referring to here and what is your issue with that option. Can you please provide more information about what you are trying to convey?
If you like our products and services, please help us by posting your review here.

felipewind
Posts: 5
Joined: Wed Nov 30, 2022 12:15 pm
Contact:

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

Post by felipewind »

Can you please confirm that I really can't add access modifiers to the anonymous inner class?

Is this a valid example of an private anonymous inner class ("Anonymous inner class may be declared private."):

Code: Select all

public class Hi {   
	private static Function<String, Integer> F = new Function<String, Integer>() {
		public Integer apply(String s) {
			return Integer.valueOf(s);
		}
	};
}
Thanks

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

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

Post by admin »

No, your example shows the keyword private being applied to the variable F and not to the anonymous inner class.
If you like our products and services, please help us by posting your review here.

felipewind
Posts: 5
Joined: Wed Nov 30, 2022 12:15 pm
Contact:

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

Post by felipewind »

admin wrote:
Fri Dec 02, 2022 9:14 am
No, your example shows the keyword private being applied to the variable F and not to the anonymous inner class.
Yes, thanks for clarifying this for me.

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests