[VV52] anonymous class, Jdbc callback, fullstack interview, Windows copilot, windows or Linux or Mac, DoD
???JAVA CERTIFICATION QUESTION:?anonymous classes
Imagine that you are doing an audit of a third-party desktop Java application
that interacts with users’ input and has the following code:
var c = new Control();
c.registerHandler(
? new Handler<Event>() {
? ? @Override
? ? void handle(Event e) {
? ? ? System.out.println("Event occurred: " + e);
? ? }
? }
);
Based on the provided code fragment, which statement is true about the Handler type? Choose one.
* It must be an interface.
* It must be an abstract class.
* It can be a concrete class.
* It can be either a class or an interface.
* It can be a class, an interface, or an enum.
* It can be a class, an interface, an enum, or a record.
???
Answer: It can be a concrete class.
In general, an anonymous class can extend a class, either a concrete or an abstract class, or it can implement an interface.
The declaration/instantiation of an anonymous class includes a parameter list.
If the parent type is a class (either abstract or concrete), that parameter list is passed to the parent class’s constructor.
If the parent type is an interface, the parameter list must be empty.
So, here, that anonymous class is not constrained to either implement an interface or extend an abstract class.
Plus, in general, an anonymous class can be derived from a concrete or abstract class or from an interface.
Then, Enum types place strict limits on their subtypes: any such subtype is implicitly final, so it cannot possibly be a subtype of an enum.
Also, any method declared in an interface will default to being public if no explicit modifier is given,
and most methods in an interface can be declared explicitly public.
Static and concrete instance methods can also be declared private.
However, no interface method can have any intermediate accessibility—that is, no interface method can have package level, or protected, accessibility.
Here if you override the interface method, it must be public.
However, the method handle(Event e) in the anonymous class has package accessibility.
So based on previous statements, it must not be an interface or abstract class, it is neither an enum nor an interface.
In the end only the statement "It can be a concrete class" is correct.
?
???? SPRING CERTIFICATION QUESTION:?Which is NOT a callback interface that works with JdbcTemplate?
* ResultSetMapper
* RowCallbackHandler
* ResultSetExtractor
* RowMapper
???
The correct answer to the question is:
`ResultSetMapper` is not a callback interface that works with `JdbcTemplate`.
While:
`ResultSetMapper`, `RowCallbackHandler`, `ResultSetExtractor`, and `RowMapper` are callback interfaces that work with `JdbcTemplate` in Spring Framework.?
Here's a brief explanation of the other callback interfaces:
1. `RowCallbackHandler`: This interface is used to process each row of the result set returned by a query.
It is used when you want to perform some custom processing for each row but don't need to return a result object.
2. `ResultSetExtractor`: This interface extracts a result object from a ResultSet.
It is typically used when you want to return a single result object (e.g., a domain object) from a query.
Best choice when multiple rows of a ResultSet map to a single object.
3. `RowMapper`: This interface maps a row of the ResultSet to an object.
It's commonly used when you want to map each row of the result set to a separate object, such as when executing a query that returns a list of objects.
Best choice when each row of a ResultSet maps to a domain object.
These callback interfaces provide flexibility and control when working with the `JdbcTemplate` in Spring by allowing you to customize the processing of query results.
?
QUOTE ???
?
Fullstack interview: prepare it with these interview questions on Angular and React
?
领英推荐
???? Windows Copilot: AI to assist you in your daily Windows use.
Check this Youtube video to see what is coming soon in Windows.
You will have a chat bound to an AI: "Windows Copilot" that will answer and operate for you:
??
?
??? POLL: What Operating System do you use for work coding? WINDOWS/LINUX/MAC
?
SCRUM: The Definition of "Done" vs Acceptance Criteria by?Ralph Jocham
There's often a misunderstanding about which is which.
DOD ??
First, let's look at the Definition Of Done (DOD).
Let's have a quick look at the scrum guide.
In the scrum guide, it states that the purpose of each sprint is to deliver increments of potentially releasable functionality.
Functionality that adheres to the current scrum team DOD.
That raises the question: "What exactly is the increment?".
The increment is the sum of all the product backlog items (PBI) completed during a sprint and the value of the increments of all the previous sprints.
It's the whole product and at the end of a sprint, your increment must be done.
That means: it must be in usable condition.
So the definition of done is about CURRENT and FUTURE PRODUCT VIABILITY.
Typical DOD ??
Especially as the scrum guide also states as the scrum team matures, it is expected that the definition of done will expand to include more stringent criteria for higher quality ??.
Often typical elements in DOD usually address?
?? the documentation concerns for users, as well as?
?? ?? technical governance,
?? If needed regulatory aspect laws and so on
?? telemetry (how can you measure user behavior changes after releases),
?? technical quality aspects (either provided directly by the organization, if not by the scrum team itself),
??? nonfunctional requirements (often approved by product owner as listed explicitly).
It is cool, especially in the early sprints when the DOD is being extended.
In that regard, it is important to have come up with a DOD before going into the very first sprint.
Remember during the Sprint review, you only demo done product functionality.
Acceptance criteria (AC) ?
From the scrum guide: "At the end of a sprint, the new increment must be done which means it must be in usable condition.
So what does "usable" mean?
During a sprint, PBI out of the product backlog is turned into the done increment.
Each of those PBI usually represents functionality that needs to be usable.
This usability is enabled by fulfilling the acceptance criteria specific to each of those PBI.
Often these AC are discovered during the product backlog refinement.
AC are there to guarantee individual FETAURE FITNESS.
AC for PBI usually addressed functionality concerns often also regards to the?
?? UI acceptance tests
?? in the form of scenarios of concrete examples, which we refer to a specification by example,?
?? input/output dataset for specific testing criteria.
AC need to be black? and white?, there is no room for interpretation.
Also AC often directly addresses Non Functional Requirements concerns to ensure product doneness.
Summary ???
DOD is about CURRENT and FUTURE PRODUCT VIABILITY
whereas the AC are about individual FEATURE FITNESS.
?
?
?? Backend developer struggling with CSS
Time to pass Fullstack!??
Java Developer
1 年Thank you, Vincent VAUBAN. May I ask you a question about anonymous class? I completely agree that Handler can't be enum or record because of their inherent restrictions. You provided good meticulous explanation why Handler can't be interface as well. I totally agree that Handler may be a concrete class. But I'm a bit confused by a statement "it must not be an interface or abstract class". I prepared code fragment for Handler as an abstract class class Event {} abstract class Handler<E extends Event> { abstract void handle(E event); } class Control { void registerHandler(Handler<? extends Event> handler) {} } and it compiles fine if combined with rest of the code. May you please explain why Handler can't be any class, either abstract or concrete? Is it just because there's no such option in questionary? Thank you.