• Stars
    star
    973
  • Rank 47,051 (Top 1.0 %)
  • Language
    Java
  • Created almost 9 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Java Interview Questions and Answers

Java Interview Questions and Answers

Image

Expectations

  • Good Java Knowledge

Complete Course Link

Things You Need to Know

Github Repository

https://github.com/in28minutes/JavaInterviewQuestionsAndAnswers

PDF Guide

Available in the resources for the course

Installing Eclipse, Java and Maven

Interview Questions

Java Platform

  • 1 . Why is Java so popular?
  • 2 . What is platform independence?
  • 3 . What is bytecode?
  • 4 . Compare JDK vs JVM vs JRE
  • 5 . What are the important differences between C++ and Java?
  • 6 . What is the role for a classloader in Java?

Wrapper Classes

  • 7 . What are Wrapper classes?
  • 8 . Why do we need Wrapper classes in Java?
  • 9 . What are the different ways of creating Wrapper class instances?
  • 10 . What are differences in the two ways of creating Wrapper classes?
  • 11 . What is auto boxing?
  • 12 . What are the advantages of auto boxing?
  • 13 . What is casting?
  • 14 . What is implicit casting?
  • 15 . What is explicit casting?

Strings

  • 16 . Are all Stringโ€™s immutable?
  • 17 . Where are String values stored in memory?
  • 18 . Why should you be careful about String concatenation(+) operator in loops?
  • 19 . How do you solve above problem?
  • 20 . What are differences between String and StringBuffer?
  • 21 . What are differences between StringBuilder and StringBuffer?
  • 22 . Can you give examples of different utility methods in String class?

Object oriented programming basics

  • 23 . What is a class?
  • 24 . What is an object?
  • 25 . What is state of an object?
  • 26 . What is behavior of an object?
  • 27 . What is the super class of every class in Java?
  • 28 . Explain about toString method ?
  • 29 . What is the use of equals method in Java?
  • 30 . What are the important things to consider when implementing equals method?
  • 31 . What is the Hashcode method used for in Java?
  • 32 . Explain inheritance with examples .
  • 33 . What is method overloading?
  • 34 . What is method overriding?
  • 35 . Can super class reference variable can hold an object of sub class?
  • 36 . Is multiple inheritance allowed in Java?
  • 37 . What is an interface?
  • 38 . How do you define an interface?
  • 39 . How do you implement an interface?
  • 40 . Can you explain a few tricky things about interfaces?
  • 41 . Can you extend an interface?
  • 42 . Can a class extend multiple interfaces?
  • 43 . What is an abstract class?
  • 44 . When do you use an abstract class?
  • 45 . How do you define an abstract method?
  • 46 . Compare abstract class vs interface?
  • 47 . What is a constructor?
  • 48 . What is a default constructor?
  • 49 . Will this code compile?
  • 50 . How do you call a super class constructor from a constructor?
  • 51 . Will this code compile?
  • 52 . What is the use of this()?
  • 53 . Can a constructor be called directly from a method?
  • 54 . Is a super class constructor called even when there is no explicit call from a sub class constructor?

Advanced object oriented concepts

  • 55 . What is polymorphism?
  • 56 . What is the use of instanceof operator in Java?
  • 57 . What is coupling?
  • 58 . What is cohesion?
  • 59 . What is encapsulation?
  • 60 . What is an inner class?
  • 61 . What is a static inner class?
  • 62 . Can you create an inner class inside a method?
  • 63 . What is an anonymous class?

Modifiers

  • 64 . What is default class modifier?
  • 65 . What is private access modifier?
  • 66 . What is default or package access modifier?
  • 67 . What is protected access modifier?
  • 68 . What is public access modifier?
  • 69 . What access types of variables can be accessed from a class in same package?
  • 70 . What access types of variables can be accessed from a class in different package?
  • 71 . What access types of variables can be accessed from a sub class in same package?
  • 72 . What access types of variables can be accessed from a sub class in different package?
  • 73 . What is the use of a final modifier on a class?
  • 74 . What is the use of a final modifier on a method?
  • 75 . What is a final variable?
  • 76 . What is a final argument?
  • 77 . What happens when a variable is marked as volatile?
  • 78 . What is a static variable?

conditions & loops

  • 79 . Why should you always use blocks around if statement?
  • 80 . Guess the output
  • 81 . Guess the output
  • 82 . Guess the output of this switch block .
  • 83 . Guess the output of this switch block?
  • 84 . Should default be the last case in a switch statement?
  • 85 . Can a switch statement be used around a String
  • 86 . Guess the output of this for loop
  • 87 . What is an enhanced for loop?
  • 88 . What is the output of the for loop below?
  • 89 . What is the output of the program below?
  • 90 . What is the output of the program below?

Exception handling

  • 91 . Why is exception handling important?
  • 92 . What design pattern is used to implement exception handling features in most languages?
  • 93 . What is the need for finally block?
  • 94 . In what scenarios is code in finally not executed?
  • 95 . Will finally be executed in the program below?
  • 96 . Is try without a catch is allowed?
  • 97 . Is try without catch and finally allowed?
  • 98 . Can you explain the hierarchy of exception handling classes?
  • 99 . What is the difference between error and exception?
  • 100 . What is the difference between checked exceptions and unchecked exceptions?
  • 101 . How do you throw an exception from a method?
  • 102 . What happens when you throw a checked exception from a method?
  • 103 . What are the options you have to eliminate compilation errors when handling checked exceptions?
  • 104 . How do you create a custom exception?
  • 105 . How do you handle multiple exception types with same exception handling block?
  • 106 . Can you explain about try with resources?
  • 107 . How does try with resources work?
  • 108 . Can you explain a few exception handling best practices?

Miscellaneous topics

  • 109 . What are the default values in an array?
  • 110 . How do you loop around an array using enhanced for loop?
  • 111 . How do you print the content of an array?
  • 112 . How do you compare two arrays?
  • 113 . What is an enum?
  • 114 . Can you use a switch statement around an enum?
  • 115 . What are variable arguments or varargs?
  • 116 . What are asserts used for?
  • 117 . When should asserts be used?
  • 118 . What is garbage collection?
  • 119 . Can you explain garbage collection with an example?
  • 120 . When is garbage collection run?
  • 121 . What are best practices on garbage collection?
  • 122 . What are initialization blocks?
  • 123 . What is a static initializer?
  • 124 . What is an instance initializer block?
  • 125 . What is tokenizing?
  • 126 . Can you give an example of tokenizing?
  • 127 . What is serialization?
  • 128 . How do you serialize an object using serializable interface?
  • 129 . How do you de-serialize in Java?
  • 130 . What do you do if only parts of the object have to be serialized?
  • 131 . How do you serialize a hierarchy of objects?
  • 132 . Are the constructors in an object invoked when it is de-serialized?
  • 133 . Are the values of static variables stored when an object is serialized?

Collections

  • 134 . Why do we need collections in Java?
  • 135 . What are the important interfaces in the collection hierarchy?
  • 136 . What are the important methods that are declared in the collection interface?
  • 137 . Can you explain briefly about the List interface?
  • 138 . Explain about ArrayList with an example?
  • 139 . Can an ArrayList have duplicate elements?
  • 140 . How do you iterate around an ArrayList using iterator?
  • 141 . How do you sort an ArrayList?
  • 142 . How do you sort elements in an ArrayList using comparable interface?
  • 143 . How do you sort elements in an ArrayList using comparator interface?
  • 144 . What is vector class? How is it different from an ArrayList?
  • 145 . What is linkedList? What interfaces does it implement? How is it different from an ArrayList?
  • 146 . Can you briefly explain about the Set interface?
  • 147 . What are the important interfaces related to the Set interface?
  • 148 . What is the difference between Set and sortedSet interfaces?
  • 149 . Can you give examples of classes that implement the Set interface?
  • 150 . What is a HashSet?
  • 151 . What is a linkedHashSet? How is different from a HashSet?
  • 152 . What is a TreeSet? How is different from a HashSet?
  • 153 . Can you give examples of implementations of navigableSet?
  • 154 . Explain briefly about Queue interface?
  • 155 . What are the important interfaces related to the Queue interface?
  • 156 . Explain about the Deque interface?
  • 157 . Explain the BlockingQueue interface?
  • 158 . What is a priorityQueue?
  • 159 . Can you give example implementations of the BlockingQueue interface?
  • 160 . Can you briefly explain about the Map interface?
  • 161 . What is difference between Map and sortedMap?
  • 162 . What is a HashMap?
  • 163 . What are the different methods in a Hash Map?
  • 164 . What is a TreeMap? How is different from a HashMap?
  • 165 . Can you give an example of implementation of navigableMap interface?
  • 166 . What are the static methods present in the collections class?

Advanced collections

  • 167 . What is the difference between synchronized and concurrent collections in Java?
  • 168 . Explain about the new concurrent collections in Java?
  • 169 . Explain about copyonwrite concurrent collections approach?
  • 170 . What is compareandswap approach?
  • 171 . What is a lock? How is it different from using synchronized approach?
  • 172 . What is initial capacity of a Java collection?
  • 173 . What is load factor?
  • 174 . When does a Java collection throw UnsupportedOperationException?
  • 175 . What is difference between fail-safe and fail-fast iterators?
  • 176 . What are atomic operations in Java?
  • 177 . What is BlockingQueue in Java?

Generics

  • 178 . What are Generics?
  • 179 . Why do we need Generics? Can you give an example of how Generics make a program more flexible?
  • 180 . How do you declare a generic class?
  • 181 . What are the restrictions in using generic type that is declared in a class declaration?
  • 182 . How can we restrict Generics to a subclass of particular class?
  • 183 . How can we restrict Generics to a super class of particular class?
  • 184 . Can you give an example of a generic method?

Multi threading

  • 185 . What is the need for threads in Java?
  • 186 . How do you create a thread?
  • 187 . How do you create a thread by extending thread class?
  • 188 . How do you create a thread by implementing runnable interface?
  • 189 . How do you run a thread in Java?
  • 190 . What are the different states of a thread?
  • 191 . What is priority of a thread? How do you change the priority of a thread?
  • 192 . What is executorservice?
  • 193 . Can you give an example for executorservice?
  • 194 . Explain different ways of creating executor services .
  • 195 . How do you check whether an executionservice task executed successfully?
  • 196 . What is callable? How do you execute a callable from executionservice?
  • 197 . What is synchronization of threads?
  • 198 . Can you give an example of a synchronized block?
  • 199 . Can a static method be synchronized?
  • 200 . What is the use of join method in threads?
  • 201 . Describe a few other important methods in threads?
  • 202 . What is a deadlock?
  • 203 . What are the important methods in Java for inter-thread communication?
  • 204 . What is the use of wait method?
  • 205 . What is the use of notify method?
  • 206 . What is the use of notifyall method?
  • 207 . Can you write a synchronized program with wait and notify methods?

Functional Programming - Lamdba expressions and Streams

  • 208 . What is functional programming?
  • 209 . Can you give an example of functional programming?
  • 210 . What is a stream?
  • 211 . Explain about streams with an example?
  • what are intermediate operations in streams?
  • 212 . What are terminal operations in streams?
  • 213 . What are method references?
  • 214 . What are lambda expressions?
  • 215 . Can you give an example of lambda expression?
  • 216 . Can you explain the relationship between lambda expression and functional interfaces?
  • 217 . What is a predicate?
  • 218 . What is the functional interface - function?
  • 219 . What is a consumer?
  • 220 . Can you give examples of functional interfaces with multiple arguments?

New Features

  • 221 . What are the new features in Java 5?
  • 222 . What are the new features in Java 6?
  • 223 . What are the new features in Java 7?
  • 224 . What are the new features in Java 8?

What you can do next?

Troubleshooting

Youtube Playlists - 500+ Videos

Click here - 30+ Playlists with 500+ Videos on Spring, Spring Boot, REST, Microservices and the Cloud

Keep Learning in28Minutes

in28Minutes is creating amazing solutions for you to learn Spring Boot, Full Stack and the Cloud - Docker, Kubernetes, AWS, React, Angular etc. - Check out all our courses here

More Repositories

1

devops-master-class

Devops Tutorial for Beginners - Learn Docker, Kubernetes, Terraform, Ansible, Jenkins and Azure Devops
Java
2,203
star
2

spring-microservices

Microservices using Spring Boot, Spring Cloud, Docker and Kubernetes
Java
1,770
star
3

java-tutorial-for-beginners

Java Tutorial For Beginners with 500 Code Examples
1,312
star
4

java-best-practices

Best practices in Coding, Designing and Architecting Java Applications
1,254
star
5

master-spring-and-spring-boot

Spring and Spring Boot Tutorial For Absolute Beginners - 10-in-1 - Spring to Spring Boot to REST API to Full Stack to Containers to Cloud
Java
1,226
star
6

spring-boot-examples

Code Examples for everything thats written on www.springboottutorial.com
Java
1,207
star
7

spring-master-class

An updated introduction to the Spring Framework 5. Become an Expert understanding the core features of Spring In Depth. You would write Unit Tests, AOP, JDBC and JPA code during the course. Includes introductions to Spring Boot, JPA, Eclipse, Maven, JUnit and Mockito.
Java
1,142
star
8

java-a-course-for-beginners

Java Programming Tutorial for Beginners
JavaScript
1,044
star
9

spring-boot-master-class

Understand and love the power of Spring Boot - All its features are illustrated developing a web application managing todos and a basic API for survey questionnaire. Also covers unit testing, mocking and integration testing.
Java
965
star
10

course-material

Course Material for in28minutes courses on Java, Spring Boot, DevOps, AWS, Google Cloud, and Azure.
947
star
11

SpringMvcStepByStep

Spring MVC Tutorial for beginners - In 25 Small Steps
Java
828
star
12

spring-microservices-v2

Microservices + Spring Boot 2 + Spring Cloud + Docker + Kubernetes - https://www.udemy.com/course/microservices-with-spring-boot-and-spring-cloud/. Latest Repo - http://github.com/in28minutes/spring-microservices-v3
JavaScript
714
star
13

learn

How do you achieve your career objectives? Complete career paths with amazing Cloud, Full Stack and Microservice Courses and Videos from in28Minutes
685
star
14

SpringIn28Minutes

Spring Tutorial For Beginners
Java
657
star
15

spring-interview-guide

200+ Questions and Answers on Spring, Spring Boot and Spring MVC
JavaScript
642
star
16

MockitoTutorialForBeginners

Mockito Tutorial for Beginners
Java
632
star
17

jpa-with-hibernate

Master JPA using Hibernate as the implementation. Learn the basics of JPA - entities, relationships, entity manager, annotations, JPQL and Criteria API. Take a step into the advanced world of JPA - caching, performance tuning(n + 1 queries), mapping inheritance hierarchies. Get a peek into the magic of Spring Data JPA & Spring Data Rest.
Java
630
star
18

SpringBootForBeginners

Spring Boot Tutorial For Beginners
Java
609
star
19

full-stack-with-react-and-spring-boot

Your First Full Stack Application with React and Spring Boot
Java
606
star
20

full-stack-with-angular-and-spring-boot

Your First Full Stack Application with Angular and Spring Boot
Java
605
star
21

in28minutes-initiatives

All initiatives to build a connect between industry, instructors and learners
596
star
22

java-cheat-sheet

Java Tutorial For Beginners - Companion Reference
588
star
23

JavaWebApplicationStepByStep

JSP Servlets Tutorial For Beginners - in 25 Steps
Java
534
star
24

spring-web-services

Spring Web Services - SOAP and RESTful
Java
532
star
25

spring-unit-testing-with-junit-and-mockito

Spring Unit Testing with JUnit and Mockito
Java
359
star
26

docker-crash-course

Docker for beginners - with Java and Spring Boot Applications and Microservices
Java
350
star
27

functional-programming-with-java

Learn Functional Programming with Java using a Hands-on Step by Step Approach
Java
340
star
28

kubernetes-crash-course

Learn Kubernetes and Docker with Google Kubernetes Engine deploying Spring Boot Microservices
Java
327
star
29

interview-guide

Java interview guide - 200+ Question and Answers
297
star
30

deploy-spring-microservices-to-aws-ecs-fargate

Take your first steps towards cloud with AWS ECS Fargate. Deploy REST APIs and Microservices with Spring Boot and Docker Containers to the cloud.
Java
265
star
31

SpringBootWebApplicationStepByStep

Develop your first web application with Spring Boot Magic
Java
256
star
32

spring-boot-react-fullstack-examples

All full stack examples with Spring Boot and React for articles on our website http://www.springboottutorial.com
JavaScript
255
star
33

roadmaps

Roadmaps of in28minutes courses!
245
star
34

spring-microservices-v3

JavaScript
228
star
35

JUnitIn28Minutes

JUNIT Tutorial For Beginners
Java
216
star
36

automation-testing-with-java-and-selenium

Learn Automation Testing with Java and Selenium
HTML
193
star
37

MavenIn28Minutes

Maven Tutorial for Beginners with Examples
Java
193
star
38

python-tutorial-for-beginners

Python Tutorial for Beginners with 500 Code Examples
182
star
39

in28minutes.github.io

Spring Boot Tutorials
HTML
171
star
40

deploy-spring-boot-aws-eb

Deploying Spring Boot Apps to AWS using Elastic Beanstalk
Java
160
star
41

getting-started-in-5-steps

How to install and get started with Java, Eclipse, Maven, JUnit, Mockito & Spring in 5 easy steps
JavaScript
154
star
42

clean-code

Learn to Write Clean Code with Java. Get Hands-on with 20+ Code Examples involving 4 principles of Simple Design, Refactoring and TDD.
JavaScript
153
star
43

first-steps-to-software-architect

How to start your journey towards software architecture?
136
star
44

MockitoIn28Minutes

Learn Mockito from In28Minutes
Java
121
star
45

learning-paths-cloud-and-devops

How to learn Cloud and DevOps
119
star
46

spring-boot-angular-fullstack-examples

All full stack examples with Spring Boot and Angular for articles on our website http://www.springboottutorial.com
TypeScript
109
star
47

in28Minutes-Course-Roadmap

A Roadmap for our Courses. Remember we focus on Java, Microservices, Web Applications and are big Spring Shop - Spring, Spring MVC, Spring Boot, Spring Cloud...
104
star
48

docker

Docker for Beginners - Learn Docker in 5 Steps
Java
101
star
49

pcf-crash-course-with-spring-boot

PCF Crash Course for Java, Spring and Spring Boot Developers - Deploy Spring Boot REST API, Full Stack Applications and Microservices to Pivotal Cloud Foundry (PCF)
Java
98
star
50

azure-devops-kubernetes-terraform-pipeline

https://github.com/in28minutes/devops-master-class
Java
87
star
51

deploy-spring-boot-to-azure

Deploy Spring Boot Applications to Azure Web Apps
Java
82
star
52

camel

Learn Enterprise Integration Patterns with Apache Camel
JavaScript
80
star
53

Design-Patterns-For-Beginners

Design Patterns for Beginners
80
star
54

JavaObjectOrientedProgramming

Learn basics of object oriented programming with Java
Java
69
star
55

learn-programming-with-python-

learn-programming-with-pythonโ€‹
Python
67
star
56

10-Steps-to-High-Quality-Java-Developer

You Key to Becoming a High Quality Java Developer
61
star
57

java-to-python-in-100-steps

Learn Python using your Java Knowledge
Python
58
star
58

java-technology-for-beginners

In my 15 years of designing and developing more than 100 java web applications, there are a number of terminologies, standards, frameworks, tools that I have used. I know how difficult it is for a beginner to understand them. And imagine the trouble non techies face - the business, testing teams and others. So, this guide is to demystify these terms! Enough talk. Let's Rock and Roll......
58
star
59

spring-boot-vuejs-fullstack-examples

All full stack examples with Spring Boot and Vue JS for articles on our website http://www.springboottutorial.com
Java
57
star
60

EclipseIn28Minutes

Eclipse Tutorial for Beginners - From in28Minutes
53
star
61

jenkin-devops-microservice

https://github.com/in28minutes/devops-master-class
Java
49
star
62

spring-complete-career-path

Level 1 covers Basics of Spring Developing a web application with Spring MVC Basics of Spring Boot - Autoconfiguration, Starter Projects Basic Todo Management Application with Login/Logout Model, Controllers, ViewResolver and Filters Forms - DataBinding, Validation Bootstrap to style the page Spring Security Exception Handling Level 2 (coming soon) will cover Rest APIs with Spring Boot SOAP Web Services with Spring Boot. Level 3 (coming soon) will cover Spring Cloud Microservices
Java
44
star
63

go-serverless

Go Serverless with AWS Lambda and Azure Functions - Udemy Course https://www.udemy.com/course/serverless-tutorial-aws-lambda-and-azure-functions
JavaScript
41
star
64

Tips-Database

Tips about Web Services, APIs, Microservices, Spring, Spring Boot, Maven, Eclipse etc
37
star
65

TDDin28Minutes

TDD Tutorial For Beginners - from in28Minutes
Java
31
star
66

spring-boot-to-cloud

Spring Boot to Cloud (AWS, Azure, GCP and PCF) with Docker and Kubernetes
Java
30
star
67

JavaTutorialForBeginners

Java Tutorial for Beginners with examples
Java
29
star
68

BasicWebServletsIn28Minutes

Java
28
star
69

campus-interview-guide

60 Day Learning Challenges for Campus Interviews
28
star
70

CTutorialForBeginners

C Tutorial for Beginners
27
star
71

Java-EE-Design-Patterns

26
star
72

HibernateJPAStepByStep

Hibernate Tutorial For Beginners - Step by Step with Examples
22
star
73

in28minutes.com

Awesome Courses from the Best Selling Instructor
HTML
22
star
74

RealWorldWebApplicationWithServletsAndJspIn28Minutes

Learn to Develop your first web application with Servlets and JSP
Java
20
star
75

cloud.in28minutes.com

cloud.in28minutes.com
HTML
20
star
76

jenkins-pipeline

Java
18
star
77

spring-boot-rest-api-playground

Java
18
star
78

spring-microservices-v3-old

JavaScript
16
star
79

microservice-reference-archetype

Java
14
star
80

hello-world-rest-api-aws-ecs-codepipeline

Java
14
star
81

Struts2StepByStep

Learn Struts 2 Step By Step
Java
11
star
82

jshell-for-java-programmers

An introduction to JShell for Java Programmers
11
star
83

hello-world-rest-api-azure-pipelines

Java
10
star
84

in28minutes

9
star
85

getting-started-for-beginners-v2

Updated Getting Started Guides for Beginners Recorded with Spring Boot 3 - Spring, Spring Boot, JUnit, Mockito, JPA, Hibernate ....
Java
9
star
86

spring-boot-todo-rest-api-h2-aws-codepipeline

Java
8
star
87

In28MinutesTemplate

Serves as template for my new courses
8
star
88

todo-app

Java
6
star
89

automatewithselenium.com

Learn how to automate your tests with Selenium - Java, Python, C# and JavaScript - automatewithselenium.com
CSS
6
star
90

dev-config-server-test

4
star
91

config-server

2
star
92

programmingabc.com

Master Content for our Programming Website - programmingabc.com
CSS
2
star
93

Future-Course-Preparation

1
star
94

hello-world-playground

Java
1
star