Skip to Content
Java Programming Interviews Exposed
book

Java Programming Interviews Exposed

by Noel Markham
February 2014
Intermediate to advanced
384 pages
9h 8m
English
Wrox
Content preview from Java Programming Interviews Exposed

Chapter 6

Design Patterns

Software design patterns use one or more objects together to solve a common use case. These use cases often focus on code reuse, extensibility, or generally providing a solid foundation for future development.

Being an object-oriented language, Java makes use of many design patterns throughout the standard library APIs, and it is quite simple to create your own implementation of some common design patterns.

This chapter looks at several common design patterns, examining some of those found in the standard Java APIs, as well as implementing some patterns too.

Hundreds, if not thousands, of software design patterns exist, and you may create some new ones that work for you in your everyday job. The patterns described here are some of the more common and well-known patterns. Interviewers often like asking questions about design patterns, because they provide scope for a lot of discussion, and they have very clear definitions.

Try the examples in this chapter, think of your own scenarios, and see if you can apply the patterns to those, too. Try to justify if a given pattern is good for a given situation, and see if you can make other patterns fit that same situation, too. It won’t always work, but sometimes it is possible for patterns to be interchanged in certain situations.

Investigating Example Patterns

How is the Builder Pattern useful?

When you want to create an object that has many fields, using constructors can become unwieldy and confusing. Imagine ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java Fundamentals

Java Fundamentals

Matt Thornfield
Java Coding Problems

Java Coding Problems

Anghel Leonard

Publisher Resources

ISBN: 9781118722886Purchase book