SlideShare a Scribd company logo
1 of 41
Java/J2EE Programming Training
Review Sessions
Page 2Classification: Restricted
Agenda
• How to prepare for a typical Java interview?
• Typical interview questions…
Interview Tips
Classification: Restricted Page 2
• How to prepare for a typical Java interview?
• Typical interview questions…
Give few reasons for using Java / Advantages of Java
over other programming languages
Classification: Restricted Page 3
• Built-in support for multi-threading, socket communication, and memory
management (automatic garbage collection).
• Object Oriented (OO).
• Better portability than other languages across operating systems
• Supports Web based applications (Applet, Servlet, and JSP), distributed
applications (sockets, RMI, EJB etc.) and network protocols (HTTP, JRMP
etc) with the help of extensive standardized APIs (Application Programming
Interfaces).
Classification: Restricted Page 4
Which package is imported implicitly by all Java programs?
The java.lang package is imported implicitly.
What are static blocks or static initializers?
Classification: Restricted Page 5
• When a class is loaded, all blocks that are declared static and don’t have
function name (i.e. static initializers) are executed even before the
constructors are executed. As the name suggests they are typically used to
initialize static fields.
Classification: Restricted Page 6
Difference between constructors and other regular methods?
• Constructors must have the same name as the class name and cannot
return a value.
• The constructors are called only once per creation of an object while regular
methods can be called many times
Can you call one constructor from another?
Classification: Restricted Page 7
Yes, by using this()
public Pet(int id) {
this.id = id; // “this” means this object
}
public Pet (int id, String type) {
this(id); // calls constructor public Pet(int id)
this.type = type; // ”this” means this object
}
How to call superclass constructor?
Classification: Restricted Page 8
By using super keyword
public SpecialPet(int id) {
super(id); //must be the very first statement in the constructor.
}
You can also use super.myMethod() to call the superclass’s myMethod. This
can be called at any line.
What happens if you do not provide a constructor?
Classification: Restricted Page 9
Java runtime provides a default constructor
Advantages of OOP?
Classification: Restricted Page 10
• Encapsulation
• Polymorphism
• Inheritance
• Abstraction
Classification: Restricted Page 11
Difference between inheritance and
composition/aggregation?
• The ‘is a’ relationship is expressed with inheritance and ‘has a’
relationship is expressed with composition. Both inheritance and
composition allow you to place sub-objects inside your new class. Two of
the main techniques for code reuse are class inheritance and object
composition
• Example: ScienceStudent is a Student; Student has an Address.
Difference between abstract class and interface?
Classification: Restricted Page 12
Refer previous session slides
• Abstract classes have executable methods and abstract methods. Interfaces
have no implementation code. All methods are abstract.
• One class can only subclass one abstract class. A class can implement any
number of interfaces
Why multiple inheritance is not allowed?
• Diamond problem
Classification: Restricted Page 13
Difference between Method Overloading vs Overriding?
Classification: Restricted Page 14
• Please refer lecture slides
Difference between Comparable and Comparator interface?
Classification: Restricted Page 15
• Please refer lecture slides
Difference between == and equals()?
Classification: Restricted Page 16
??
Explain the non-final methods toString(), hashCode()
and equals() of Object class
Classification: Restricted Page 17
• Refer lecture
Difference between String and StringBuffer/StringBuilder
Classification: Restricted Page 18
• Please refer lecture
Explain the different access modifiers..
Classification: Restricted Page 19
• Public
• Private
• Default
• Protected
Code output?
Classification: Restricted Page 20
Code output?
c. Autoboxing will convert a short to a Short, but not to an Integer.
Classification: Restricted Page 21
Code output?
Classification: Restricted Page 22
Code output?
a. "j" will be converted to an Integer automatically when it is
passed to compareTo().
Classification: Restricted Page 23
Code output?
Classification: Restricted Page 24
Code output?
d. "i" will not be converted to an Integer automatically
because there is no assignment nor casting there.
Classification: Restricted Page 25
What is the output?
Classification: Restricted Page 26
What is the output?
It will print “a”. The g() in Bar is not overriding the g() in Foo. It is
just overloading the name "g". When determining which method to
call, autoboxing is not considered first so only the g() in Foo is
applicable and thus is used.
Classification: Restricted Page 27
True or False
Classification: Restricted Page 28
“X extends Y” is correct if and only if X is a class and Y is an interface.
True or False
Classification: Restricted Page 29
“X extends Y” is correct if and only if X is a class and Y is an interface.
False
Question
Classification: Restricted Page 30
Question
B and D
Classification: Restricted Page 31
What is the output?
Classification: Restricted Page 32
What is the output?
Compilation error on lines that print f.a and f.b
Classification: Restricted Page 33
Which of these is not correct?
Classification: Restricted Page 34
Which of these is not correct?
All are correct
Classification: Restricted Page 35
What is the output?
Classification: Restricted Page 36
What is the output?
Compilation error… cannot invoke countGold from
static context
Classification: Restricted Page 37
What is the difference between a List and a Set?
Classification: Restricted Page 38
Set:
HashSet: Default Set …must implement equals and hashCode
LinkedHashSet: Maintains the elements in the order in which they were
entered
TreeSet: Maintains in ascending order/sorted
TreeSet<Student> ts = new TreeSet<Student>();
Comparable: Default comparison logic…. Student implements Comparable…
override compareTo()
Comparator: Multiple Comparator classes by implementing Comparator
and overriding compare()
What is the difference between a List and a Set?
Classification: Restricted Page 39
• List, by default characteristic maintains order; a set does not.
• A set does not entertain duplicate members; whereas a List does
Thank You

More Related Content

What's hot

Object Oriented Concepts in Real Projects
Object Oriented Concepts in Real ProjectsObject Oriented Concepts in Real Projects
Object Oriented Concepts in Real ProjectsEPAM
 
Java basic data types
Java basic data typesJava basic data types
Java basic data types3trg
 
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...Simplilearn
 
Java Data Types and Variables
Java Data Types and VariablesJava Data Types and Variables
Java Data Types and Variablessasi saseenthiran
 
Data types in Java
Data types in JavaData types in Java
Data types in JavaPlay Store
 
OntoLex-TEI: Inspiration from Global WordNet
OntoLex-TEI: Inspiration from Global WordNetOntoLex-TEI: Inspiration from Global WordNet
OntoLex-TEI: Inspiration from Global WordNetPretaLLOD
 
Primitive data types in java
Primitive data types in javaPrimitive data types in java
Primitive data types in javaUmamaheshwariv1
 
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...Simplilearn
 
Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?NexSoftsys
 
332 ch07
332 ch07332 ch07
332 ch07YaQ10
 
Handout for Dublin Core Metadata Initiative Abstract Model
Handout for Dublin Core Metadata Initiative Abstract ModelHandout for Dublin Core Metadata Initiative Abstract Model
Handout for Dublin Core Metadata Initiative Abstract ModelJenn Riley
 
Session 11 - OOP's with Java - Packaging and Access Modifiers
Session 11 - OOP's with Java - Packaging and Access ModifiersSession 11 - OOP's with Java - Packaging and Access Modifiers
Session 11 - OOP's with Java - Packaging and Access ModifiersPawanMM
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm Madishetty Prathibha
 
Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objectsrahulsahay19
 
Ballerina philosophy
Ballerina philosophy Ballerina philosophy
Ballerina philosophy Ballerina
 

What's hot (20)

Object Oriented Concepts in Real Projects
Object Oriented Concepts in Real ProjectsObject Oriented Concepts in Real Projects
Object Oriented Concepts in Real Projects
 
Java basic data types
Java basic data typesJava basic data types
Java basic data types
 
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
Abstract Class In Java | Java Abstract Class Tutorial | Java Tutorial For Beg...
 
Java Data Types and Variables
Java Data Types and VariablesJava Data Types and Variables
Java Data Types and Variables
 
Data types
Data typesData types
Data types
 
Data types in Java
Data types in JavaData types in Java
Data types in Java
 
Value Types
Value TypesValue Types
Value Types
 
OntoLex-TEI: Inspiration from Global WordNet
OntoLex-TEI: Inspiration from Global WordNetOntoLex-TEI: Inspiration from Global WordNet
OntoLex-TEI: Inspiration from Global WordNet
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
 
Primitive data types in java
Primitive data types in javaPrimitive data types in java
Primitive data types in java
 
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
 
Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?Why Java is not a purely object oriented language?
Why Java is not a purely object oriented language?
 
332 ch07
332 ch07332 ch07
332 ch07
 
Handout for Dublin Core Metadata Initiative Abstract Model
Handout for Dublin Core Metadata Initiative Abstract ModelHandout for Dublin Core Metadata Initiative Abstract Model
Handout for Dublin Core Metadata Initiative Abstract Model
 
Session 11 - OOP's with Java - Packaging and Access Modifiers
Session 11 - OOP's with Java - Packaging and Access ModifiersSession 11 - OOP's with Java - Packaging and Access Modifiers
Session 11 - OOP's with Java - Packaging and Access Modifiers
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
 
Classes And Objects
Classes And ObjectsClasses And Objects
Classes And Objects
 
Ballerina philosophy
Ballerina philosophy Ballerina philosophy
Ballerina philosophy
 
Data types IN JAVA
Data types IN JAVAData types IN JAVA
Data types IN JAVA
 

Similar to Review Session and Attending Java Interviews

Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Hitesh-Java
 
Framework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users GroupFramework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users Groupbrada
 
Delta final paper
Delta final paperDelta final paper
Delta final paperprabhatjon
 
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questionsnicolbiden
 
findbugs Bernhard Merkle
findbugs Bernhard Merklefindbugs Bernhard Merkle
findbugs Bernhard Merklebmerkle
 
Compiler2016 by abcdabcd987
Compiler2016 by abcdabcd987Compiler2016 by abcdabcd987
Compiler2016 by abcdabcd987乐群 陈
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developementfrwebhelp
 
Hibernate basics
Hibernate basicsHibernate basics
Hibernate basicsAathikaJava
 
Java Hibernate Basics
Java Hibernate BasicsJava Hibernate Basics
Java Hibernate BasicsDeeptiJava
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java BasicsFayis-QA
 
Evolving The Java Language
Evolving The Java LanguageEvolving The Java Language
Evolving The Java LanguageQConLondon2008
 
C# Interview Questions | Edureka
C# Interview Questions | EdurekaC# Interview Questions | Edureka
C# Interview Questions | EdurekaEdureka!
 
Lecture 5 interface.pdf
Lecture  5 interface.pdfLecture  5 interface.pdf
Lecture 5 interface.pdfAdilAijaz3
 
Session 04 - Arrays in Java
Session 04 - Arrays in JavaSession 04 - Arrays in Java
Session 04 - Arrays in JavaPawanMM
 

Similar to Review Session and Attending Java Interviews (20)

Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Review Session and Attending Java Interviews
Review Session and Attending Java Interviews
 
Framework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users GroupFramework Design Guidelines For Brussels Users Group
Framework Design Guidelines For Brussels Users Group
 
Delta final paper
Delta final paperDelta final paper
Delta final paper
 
C# interview-questions
C# interview-questionsC# interview-questions
C# interview-questions
 
findbugs Bernhard Merkle
findbugs Bernhard Merklefindbugs Bernhard Merkle
findbugs Bernhard Merkle
 
Compiler2016 by abcdabcd987
Compiler2016 by abcdabcd987Compiler2016 by abcdabcd987
Compiler2016 by abcdabcd987
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Cse java
Cse javaCse java
Cse java
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developement
 
Ej Chpt#4 Final
Ej Chpt#4 FinalEj Chpt#4 Final
Ej Chpt#4 Final
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
Hibernate basics
Hibernate basicsHibernate basics
Hibernate basics
 
Java Hibernate Basics
Java Hibernate BasicsJava Hibernate Basics
Java Hibernate Basics
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basics
 
Hibernate I
Hibernate IHibernate I
Hibernate I
 
Evolving The Java Language
Evolving The Java LanguageEvolving The Java Language
Evolving The Java Language
 
Core_Java_Interview.pdf
Core_Java_Interview.pdfCore_Java_Interview.pdf
Core_Java_Interview.pdf
 
C# Interview Questions | Edureka
C# Interview Questions | EdurekaC# Interview Questions | Edureka
C# Interview Questions | Edureka
 
Lecture 5 interface.pdf
Lecture  5 interface.pdfLecture  5 interface.pdf
Lecture 5 interface.pdf
 
Session 04 - Arrays in Java
Session 04 - Arrays in JavaSession 04 - Arrays in Java
Session 04 - Arrays in Java
 

More from RatnaJava

Collections - Lists & sets
Collections - Lists & setsCollections - Lists & sets
Collections - Lists & setsRatnaJava
 
Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing BasicsCollections - Sorting, Comparing Basics
Collections - Sorting, Comparing BasicsRatnaJava
 
Collections Array list
Collections Array listCollections Array list
Collections Array listRatnaJava
 
Object Class
Object ClassObject Class
Object ClassRatnaJava
 
Exception Handling
Exception Handling  Exception Handling
Exception Handling RatnaJava
 
OOPs with Java - Packaging and Access Modifiers
OOPs with Java - Packaging and Access ModifiersOOPs with Java - Packaging and Access Modifiers
OOPs with Java - Packaging and Access ModifiersRatnaJava
 
OOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesOOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesRatnaJava
 
OOP with Java - Part 3
OOP with Java - Part 3OOP with Java - Part 3
OOP with Java - Part 3RatnaJava
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continuedRatnaJava
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingRatnaJava
 
Data Handling and Function
Data Handling and FunctionData Handling and Function
Data Handling and FunctionRatnaJava
 
Introduction to Java Part-3
Introduction to Java Part-3Introduction to Java Part-3
Introduction to Java Part-3RatnaJava
 
Introduction to Java Part-2
Introduction to Java Part-2Introduction to Java Part-2
Introduction to Java Part-2RatnaJava
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java RatnaJava
 

More from RatnaJava (14)

Collections - Lists & sets
Collections - Lists & setsCollections - Lists & sets
Collections - Lists & sets
 
Collections - Sorting, Comparing Basics
Collections - Sorting, Comparing BasicsCollections - Sorting, Comparing Basics
Collections - Sorting, Comparing Basics
 
Collections Array list
Collections Array listCollections Array list
Collections Array list
 
Object Class
Object ClassObject Class
Object Class
 
Exception Handling
Exception Handling  Exception Handling
Exception Handling
 
OOPs with Java - Packaging and Access Modifiers
OOPs with Java - Packaging and Access ModifiersOOPs with Java - Packaging and Access Modifiers
OOPs with Java - Packaging and Access Modifiers
 
OOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesOOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and Interfaces
 
OOP with Java - Part 3
OOP with Java - Part 3OOP with Java - Part 3
OOP with Java - Part 3
 
OOP with Java - continued
OOP with Java - continuedOOP with Java - continued
OOP with Java - continued
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Data Handling and Function
Data Handling and FunctionData Handling and Function
Data Handling and Function
 
Introduction to Java Part-3
Introduction to Java Part-3Introduction to Java Part-3
Introduction to Java Part-3
 
Introduction to Java Part-2
Introduction to Java Part-2Introduction to Java Part-2
Introduction to Java Part-2
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java
 

Recently uploaded

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Recently uploaded (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

Review Session and Attending Java Interviews

  • 2. Page 2Classification: Restricted Agenda • How to prepare for a typical Java interview? • Typical interview questions…
  • 3. Interview Tips Classification: Restricted Page 2 • How to prepare for a typical Java interview? • Typical interview questions…
  • 4. Give few reasons for using Java / Advantages of Java over other programming languages Classification: Restricted Page 3 • Built-in support for multi-threading, socket communication, and memory management (automatic garbage collection). • Object Oriented (OO). • Better portability than other languages across operating systems • Supports Web based applications (Applet, Servlet, and JSP), distributed applications (sockets, RMI, EJB etc.) and network protocols (HTTP, JRMP etc) with the help of extensive standardized APIs (Application Programming Interfaces).
  • 5. Classification: Restricted Page 4 Which package is imported implicitly by all Java programs? The java.lang package is imported implicitly.
  • 6. What are static blocks or static initializers? Classification: Restricted Page 5 • When a class is loaded, all blocks that are declared static and don’t have function name (i.e. static initializers) are executed even before the constructors are executed. As the name suggests they are typically used to initialize static fields.
  • 7. Classification: Restricted Page 6 Difference between constructors and other regular methods? • Constructors must have the same name as the class name and cannot return a value. • The constructors are called only once per creation of an object while regular methods can be called many times
  • 8. Can you call one constructor from another? Classification: Restricted Page 7 Yes, by using this() public Pet(int id) { this.id = id; // “this” means this object } public Pet (int id, String type) { this(id); // calls constructor public Pet(int id) this.type = type; // ”this” means this object }
  • 9. How to call superclass constructor? Classification: Restricted Page 8 By using super keyword public SpecialPet(int id) { super(id); //must be the very first statement in the constructor. } You can also use super.myMethod() to call the superclass’s myMethod. This can be called at any line.
  • 10. What happens if you do not provide a constructor? Classification: Restricted Page 9 Java runtime provides a default constructor
  • 11. Advantages of OOP? Classification: Restricted Page 10 • Encapsulation • Polymorphism • Inheritance • Abstraction
  • 12. Classification: Restricted Page 11 Difference between inheritance and composition/aggregation? • The ‘is a’ relationship is expressed with inheritance and ‘has a’ relationship is expressed with composition. Both inheritance and composition allow you to place sub-objects inside your new class. Two of the main techniques for code reuse are class inheritance and object composition • Example: ScienceStudent is a Student; Student has an Address.
  • 13. Difference between abstract class and interface? Classification: Restricted Page 12 Refer previous session slides • Abstract classes have executable methods and abstract methods. Interfaces have no implementation code. All methods are abstract. • One class can only subclass one abstract class. A class can implement any number of interfaces
  • 14. Why multiple inheritance is not allowed? • Diamond problem Classification: Restricted Page 13
  • 15. Difference between Method Overloading vs Overriding? Classification: Restricted Page 14 • Please refer lecture slides
  • 16. Difference between Comparable and Comparator interface? Classification: Restricted Page 15 • Please refer lecture slides
  • 17. Difference between == and equals()? Classification: Restricted Page 16 ??
  • 18. Explain the non-final methods toString(), hashCode() and equals() of Object class Classification: Restricted Page 17 • Refer lecture
  • 19. Difference between String and StringBuffer/StringBuilder Classification: Restricted Page 18 • Please refer lecture
  • 20. Explain the different access modifiers.. Classification: Restricted Page 19 • Public • Private • Default • Protected
  • 22. Code output? c. Autoboxing will convert a short to a Short, but not to an Integer. Classification: Restricted Page 21
  • 24. Code output? a. "j" will be converted to an Integer automatically when it is passed to compareTo(). Classification: Restricted Page 23
  • 26. Code output? d. "i" will not be converted to an Integer automatically because there is no assignment nor casting there. Classification: Restricted Page 25
  • 27. What is the output? Classification: Restricted Page 26
  • 28. What is the output? It will print “a”. The g() in Bar is not overriding the g() in Foo. It is just overloading the name "g". When determining which method to call, autoboxing is not considered first so only the g() in Foo is applicable and thus is used. Classification: Restricted Page 27
  • 29. True or False Classification: Restricted Page 28 “X extends Y” is correct if and only if X is a class and Y is an interface.
  • 30. True or False Classification: Restricted Page 29 “X extends Y” is correct if and only if X is a class and Y is an interface. False
  • 32. Question B and D Classification: Restricted Page 31
  • 33. What is the output? Classification: Restricted Page 32
  • 34. What is the output? Compilation error on lines that print f.a and f.b Classification: Restricted Page 33
  • 35. Which of these is not correct? Classification: Restricted Page 34
  • 36. Which of these is not correct? All are correct Classification: Restricted Page 35
  • 37. What is the output? Classification: Restricted Page 36
  • 38. What is the output? Compilation error… cannot invoke countGold from static context Classification: Restricted Page 37
  • 39. What is the difference between a List and a Set? Classification: Restricted Page 38 Set: HashSet: Default Set …must implement equals and hashCode LinkedHashSet: Maintains the elements in the order in which they were entered TreeSet: Maintains in ascending order/sorted TreeSet<Student> ts = new TreeSet<Student>(); Comparable: Default comparison logic…. Student implements Comparable… override compareTo() Comparator: Multiple Comparator classes by implementing Comparator and overriding compare()
  • 40. What is the difference between a List and a Set? Classification: Restricted Page 39 • List, by default characteristic maintains order; a set does not. • A set does not entertain duplicate members; whereas a List does