[VV27] abrupt completion, spring logging, react vs angular, naming conventions, chatGPT press review
???JAVA CERTIFICATION QUESTION:?abrupt completion
Given these two exception classes:
class BatteryException extends Exception { }
class FuelException extends Exception { }
And the following Car class:
public class Car {
?public String checkBattery() throws BatteryException {
??// implementation
?}
?public String checkFuel() throws FuelException {
??// implementation
?}
?public String start() {
??try {
???checkBattery();
???checkFuel();
??} catch (BatteryException be) {
???return "BadBattery";
??} finally {
???return "";
??}
?}
}
Which statement is correct about the start() method? Choose one.
* It may return BadBattery or an empty string.
* It can only return an empty string.
* It may throw FuelException.
* It will cause a compilation error because FuelException is not handled.
Answer: It can only return an empty string.
Looking at the code, notice that there are two domain-specific exceptions related to the battery and the fuel.
They’re direct subtypes of Exception, which means that they are checked exceptions.
If such an exception might be thrown by a method, it must be declared in the throws clause of that method.
The usual way to handle an exception inside a method is to use a try-catch structure and provide a catch block that names the exception, or a parent type of that exception.
In this code, there’s a catch block for the BatteryException but not for the FuelException.
Given that the method does not declare throws FuelException, you might expect the compiler to refuse to compile the code.
However, if you think a bit deeper on this, you should realize that the finally block executes return "".
This does exactly what it says: No matter how the code reaches the finally block, the result is that the method will return an empty string.
No exceptions will be thrown; indeed, any FuelException that might arise will simply be abandoned.
In other words, because FuelException is never thrown by the method, it’s not necessary to declare it in a throws clause.
This phenomenon is called: "abrupt completion".
The return statement always completes abruptly.
So the return statement in the finally block supersedes the behaviors of the try/catch exception handling.
You know that the return "" in the finally block is always executed because there are no paths through the method that do not enter the try construct.
Putting this together with the specification excerpts above, you can see that the only possible result of executing the method is abrupt completion, which returns an empty string.
?
????? SPRING CERTIFICATION QUESTION:?How can you control logging with Spring Boot?
Answer:
Even though Spring Boot is an 'opinionated' framework,
its true power comes with the possibility to customize each and every pre-configured layer.
When it comes to logging the following can be changed:
- log level of the core Spring loggers (container, Hibernate, Spring Boot):
-- specify <code>--debug</code> or <code>--trace</code> flag.
-- specify application property <code>debug=true</code>, <code>trace=true</code>.
- message color of console output.
- file output using <code>logging.file</code> or <code>logging.path</code> application property.
- logging level of specific classes or logging groups.
- specify different logging implementation by including libraries on the classpath (logback is used by default).
Logging in Spring Boot ?? https://www.baeldung.com/spring-boot-logging
?
QUOTE ???
?
领英推荐
React VS Angular
?? Performance: React has high performance, is great for scalability, and offers more flexibility than Angular.
?? Ease of Learning: Angular has a steeper learning curve whereas React is generally considered easier to learn than Angular.
?? Use Case: React is best suited for building small to medium-sized applications whereas Angular is better suited for building large-scale enterprise applications.
?? Flexibility: React is more flexible than Angular, as it is a library rather than a full-featured framework.
??Scalability: React is easily scalable as compared to Angular.
?? Creator: React is a JS library developed by Facebook that allows you to build UI components. Angular is a structural framework developed by Google for developing dynamic web apps.
?? Syntax: React uses a virtual DOM & JSX (a syntax extension of JavaScript). Angular uses real DOM & HTML templates.
?? Pattern: React mainly focused on the view layer of an application. Angular is full-fledged MVC framework.
??Librairies: react is more flexible & has a larger ecosystem of third-party libraries and plugins. Angular has a more standardized approach & comes with its own set of tools and libraries.
?? Data binding: React has one-way data binding & supports server-side rendering. Angular has two-way data binding & does not have built-in support for server-side rendering.
?? Dependency Injection: react is written in JavaScript & does not use the Dependency Injection concept. Angular is written in TypeScript & uses a hierarchical Dependency Injection system.
?? Use Case: React is preferred when the dynamic content need is intensive. Angular is preferred for large applications like video streaming app.
?? References: React is used by companies Facebook, Instagram, Twitter, Airbnb, Netflix, Paypal, Uber, etc. Angular is used by companies Google, Forbes, Youtube, Wix, telegram, etc.
?
SCRUM DEVELOPER CONCEPT: naming convention benefits
- Helps to formalize and promote consistency within a team.
- Improves clarity in case of ambiguity.
- Avoids naming conflicts
- Allows transferring the project to another team with reduced costs.
- Improves understanding for everybody.
?
?????#chatgGPT press review ?????: ChatGPT, a great assistant that is already seducing professionals
[Intro] The artificial intelligence developed by OpenAI has become a part of the daily routine of numerous French companies, despite its limitations.
1) ChatGPT allows for considerable time-saving.
1a) It quickly produces numerous technical documents that are simple to create but extremely lengthy.
1b) When coding, ChatGPT identifies anomalies that the human eye may struggle to see.
1c) Although ChatGPT was only released three months ago, some professionals in France already use it daily. Its uses are multiple, including content creation, data analysis, customer assistance, as well as ideas or concepts generation, and the benefits provided by this now famous AI are manifold."
2) A tool not so easy to use effectively.
2a) It is a real job to provide the right information to ChatGPT.
2b) ChatGPT can "give a wrong answer with incredible confidence."
2c) The number of requests is limited to around 30 per hour for the free version.
2d) Too many simultaneous users can cause blockages.
[Outro] Will this artificial intelligence exceed its role as a great assistant?
Despite its limitations, ChatGPT proves to be of great help for their activity.
It is a complementary tool that enhances work efficiency.
But the next version of ChatGPT should be released very soon, and OpenAI promises to take it to the next level.
?
???? Chuck
Chuck Norris rewrote the Google search engine from scratch.
Hello Vincent... We post 100's of job opportunities for developers daily here. Candidates can talk to HRs directly. Feel free to share it with your network. Visit this link - https://jobs.hulkhire.com And start applying.. Will be happy to address your concerns, if any