• final – constant declaration.
  • finally – The finally block always executes when the try block exits, except System.exit(0) call. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated.
  • finalize() – method helps in garbage collection. A method that is invoked before an object is discarded by the garbage collector, allowing it to clean up its state. Should not be used to release non-memory resources like file handles, sockets, database connections etc because Java has only a finite number of these resources and you do not know when the garbage collection is going to kick in to release these non-memory resources through the finalize() method.

In simple words::

final variables are unchangeable.
final classes are not subclassed.
final methods are not overriden.

finilize() to clean up memory resourses for object using finilize().

finally block is executed if exception thrown or not.

Question: When Smoke & Sanity Testing is performed in the STLC? Which of them is performed earlier & the other later & why?

Ans: Sanity testing: It is just to test the basic functionalities of a software product and application. it is done by testers.
Sanity Testing is subset of regression testing and a group of test cases are executed that are related with the changes made to the application.

Smoke testing: it is a form of regression testing. When an application made some new changes to modules or added new modules to a application then a smoke test is performed that it is working fine or not. It can be done by both developers and testers but most of time dev team perform this.
In software engineering, a smoke test generally consists of a collection of tests that can be applied to a newly created or repaired computer program. Sometimes the tests are performed by the automated system that builds the final software. In this sense a smoke test is the process of validating code changes before the changes are checked into the larger product’s official source code collection or the main branch of source code.
A Smoke test is designed to touch every part of the application in a cursory way. It’s shallow and wide
There are no certain rules for this, the both ensure whatever we are releasing it should be defect free and tester should catch defect ASAP so we can reduce time and cost to deliver best product.
In Some organizations, Sanity Testing is done first and then Smoke testing because Sanity Testing is a sub set of major function testing to check build is stable or not and major function working fine or not and smoke testing is like cursor testing where user just touch every part of the application it can be called as ad-hoc.
But in some organizations, Smoke is done first and later the sanity, but again its depend on organization to organization
Software sanity tests are commonly conflated with smoke tests. A smoke test determines whether it is possible to continue testing, as opposed to whether it is reasonable. A software smoke test determines whether the program launches and whether its interfaces are accessible and responsive. If the smoke test fails, it is impossible to conduct a sanity test.
In contrast, the ideal sanity test exercises the smallest subset of application functions needed to determine whether the application logic is generally functional and correct. If the sanity test fails, it is not reasonable to attempt more rigorous testing.
Both sanity tests and smoke tests are ways to avoid wasting time and effort by quickly determining whether an application is too flawed to merit any rigorous testing. Many companies run sanity tests and unit tests on an automated build as part of their development process.

TRAPS: Believe it or not, this is a killer question because so many candidates are unprepared for it. If you stammer or adlib you’ve blown it.

BEST ANSWER: By now you can see how critical it is to apply the overall strategy of uncovering the employer’s needs before you answer questions. If you know the employer’s greatest needs and desires, this question will give you a big leg up over other candidates because you will give him better reasons for hiring you than anyone else is likely to…reasons tied directly to his needs.

Whether your interviewer asks you this question explicitly or not, this is the most important question of your interview because he must answer this question favorably in is own mind before you will be hired. So help him out! Walk through each of the position’s requirements as you understand them, and follow each with a reason why you meet that requirement so well.

Example: “As I understand your needs, you are first and foremost looking for someone who can manage the sales and marketing of your book publishing division. As you’ve said you need someone with a strong background in trade book sales. This is where

I’ve spent almost my entire career, so I’ve chalked up 18 years of experience exactly in this area. I believe that I know the right contacts, methods, principles, and successful management techniques as well as any person can in our industry.”

“You also need someone who can expand your book distribution channels. In my prior post, my innovative promotional ideas doubled, then tripled, the number of outlets selling our books. I’m confident I can do the same for you.”

“You need someone to give a new shot in the arm to your mail order sales, someone who knows how to sell in space and direct mail media. Here, too, I believe I have exactly the experience you need. In the last five years, I’ve increased our mail order book sales from $600,000 to $2,800,000, and now we’re the country’s second leading marketer of scientific and medical books by mail.” Etc., etc., etc.,

Every one of these selling “couplets” (his need matched by your qualifications) is a touchdown that runs up your score. IT is your best opportunity to outsell your competition.

TRAPS: There are some questions your interviewer has no business asking, and this is one. But while you may feel like answering, “none of your business,” naturally you can’t. Some interviewers ask this question on the chance you admit to something, but if not, at least they’ll see how you think on your feet. Some unprepared candidates, flustered by this question, unburden themselves of guilt from their personal life or career, perhaps expressing regrets regarding a parent, spouse, child, etc. All such answers can be disastrous. 

BEST ANSWER: As with faults and weaknesses, never confess regret. But don’t seem as if you’re stonewalling either. Best strategy: Say you harbor no regrets, then add a principle or habit you practice regularly for healthy human relations. 

Example: Pause for reflection, as if the question never occurred to you. Then say, “You know, I really can’t think of anything.” (Pause again, and then add): “I would add that as a general management principle, I’ve found that the best way to avoid regrets is to avoid causing them in the first place. I practice one habit that helps me a great deal in this regard. At the end of each day, I mentally review the day’s events and conversations to take a second look at the people and developments I’m involved with and do a double-check of what they’re likely to be feeling. Sometimes I’ll see things that do need more follow-up, whether a pat on the back, or maybe a five minute chat in someone’s office to make sure we’re clear on things…whatever.” “I also like to make each person feel like a member of an elite team, like the Boston Celtics or LA Lakers in their prime. I’ve found that if you let each team member know you expect excellence in their performance…if you work hard to set an example yourself…and if you let people know you appreciate and respect their feelings, you wind up with a highly motivated group, a team that’s having fun at work because they’re striving for excellence rather than brooding over slights or regrets.” 

TRAPS: Beware - this is an eliminator question, designed to shorten the candidate list.

Any admission of a weakness or fault will earn you an “A” for honesty, but an “F” for the interview.

PASSABLE ANSWER: Disguise strength as a weakness.

Example: “I sometimes push my people too hard. I like to work with a sense of urgency and everyone is not always on the same wavelength.”

Drawback: This strategy is better than admitting a flaw, but it’s so widely used; it is transparent to any experienced interviewer.

BEST ANSWER: (and another reason it’s so important to get a thorough description of your interviewer’s needs before you answer questions): Assure the interviewer that you can think of nothing that would stand in the way of your performing in this position with excellence. Then, quickly review you strongest qualifications.

Example: “Nobody’s perfect, but based on what you’ve told me about this position, I believe I’ d make an outstanding match. I know that when I hire people, I look for two things most of all. Do they have the qualifications to do the job well, and the motivation to do it well? Everything in my background shows I have both the qualifications and a strong desire to achieve excellence in whatever I take on. So I can say in all honesty that I see nothing that would cause you even a small concern about my ability or my strong desire to perform this job with excellence.”

Alternate strategy (if you don’t yet know enough about the position to talk about such a perfect fit.

Instead of confessing a weakness, describe what you like most and like least, making sure that what you like most matches up with the most important qualification for success in the position, and what you like least is not essential.

Example: Let’s say you’re applying for a teaching position. “If given a choice, I like to spend as much time as possible in front of my prospects selling, as opposed to shuffling paperwork back at the office. Of course, I long ago learned the importance of filing paperwork properly, and I do it conscientiously. But what I really love to do is sell (if your interviewer were a sales manager, this should be music to his ears.)