Blog Archives
1 8 9 10 11 12 13 14 15 16 28

06: Mockito & PowerMock for mocking static methods

This extends Part 4: Mockito & PowerMock for partially mocking private methods to mock “static” methods.

How to use both Spring JUnit and PowerMock runners?

By using the “@PowerMockRunnerDelegate” from the “powermock-module-junit4” jar.

So, need to use compatible “Mockito”

Read more ›



06: Q25 – Q32 SOLID design principles interview questions & answers for Java developers

Design principles interview questions & answers for Java developers so that you can expand your OOP skills to design robust Java apps Q25. What are the SOLID design principles? A25. SOLID is an abbreviation for 5 design principles. SRP (Single Responsibility Principle) If you have a class with calculation logic,...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


06: RESTful Web services and HATEOAS Q&A

Q1. What is HATEOAS? How does it provide state transition, scalability, and loose coupling? A1. HATEOAS (Hypermedia as the Engine of Application State) is considered the final level of REST. This means that each link is presumed to implement the standard REST verbs of GET, … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


06: Spring 4 MVC RESTful GET & POST methods Web Services Tutorial

This tutorial extends Spring 4 MVC RESTful Web Service Beginner Tutorial step by step.

Controller that supports GET with path variable & POST methods

Step 1: The “AccountController.java” that has two additional methods to support requests like

GET: http://localhost:8080/simpleWeb/entry/v1/forecasting/account/123

POST: http://localhost:8080/simpleWeb/entry/v1/forecasting/account

Step 2: Package as simpleWeb.war and deploy to Tomcat’s “webapps”

Read more ›



06: What is Wrong with this code? Multithreading & wait/notify

An excellent written test question to assess your Java multi-threading knowledge. Please practice it by doing it yourself.

Q. Review the code shown below and then answer the following questions.

Q1. What does the above code do?
Q2. What are the issues with the above code?

Read more ›



07: 20+ Pre interview refresher on tools

Experienced developers know what tools to use to get the job done. I often forget code quality tool names like Sonar, FindBugs, Crucible, etc, penetration testing tools like Skipfish, and ETL tools like Datastage to name a few. So, it is worth refreshing your memory prior to job interviews. Eclipse/IntelliJ/NetBeans:...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


07: Hibernate mistakes – accessing objects outside of a transaction

Hibernate does require the same EntityManager to be available in order to lazily load objects. If you have no EntityManager, then you have no knowledge of the datastore. Once the transaction is committed the objects become detached, and you can’t lazy load detached objects. So, you need to lazily load...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


07: Index of long consecutive characters in a string – flow control

Q. Complete the method “int startIndexOfLongestRun(String input)” that returns the start index of a character that has the longest consecutive count.

A. A map cannot be used here as the same character can repeated. For example, … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


07: Java 9 to 20 features interview Q&As – JShell & Collection factory methods

Q01: What is a JShell in Java? A01: JShell was introduced in Java 9, and it is a Read-Evaluate-Print-Loop (aka REPL). It provides an interactive shell for quickly prototyping, debugging, and learning Java and Java APIs. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


07: JMockit interview Q&As & examples on replaying with result field, returns(…) method & Delegate interface

When using JMockit, there are 3 different ways of defining the expected result of the invocation of a mocked method. 1) result field, which we have been using the previous posts. It could be a value:

or an exception:

2) returns(Object…) method is a syntactic sugar for returning...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


07: Q33 Top 5 OOP tips for Java developers

Tip #1: Tightly encapsulate your classes. A class generally contains data as well as methods, and is responsible for the integrity of its own data. The standard way to protect the data is to make it private, so that no other class can get direct access to it, … Read more...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


07: Tree – Sum Levels Java example

Q. Write code to traverse a tree and return the sum of the values (Node.getValue()) of all nodes at the level N in the tree?

A. Let’s have a basic implementation of the above Node interface. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


07: What is wrong with this code? Multithreading & locks

Q. What is wrong with the following Java code? Explain what does the following code do? Explain if there is anything wrong with the following code? If there is something wrong, how will you go about fixing it?

A. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


1 8 9 10 11 12 13 14 15 16 28

300+ Java Interview FAQs

Tutorials on Java & Big Data