SlideShare a Scribd company logo
1 of 12
1. What is the pillar of oops concept
Encapsulation
Inheritance
Polymorphism
Abstraction
2. Where did you use this concepts in your project
3. Explain Exception hierarchy in Inheritance
4. parent child override scenario
5. can we override static and private method ?
6. what is the difference of java 7 and java 8 interface
Java 8 Default method ,static method
Interview Q&A
7. What is final, finally and finalize ?
 final : keyword
 finally : block
 finalize : method
8. What is equals and hashcode method and its contract
 Hashcode : used to generate unique or reference number of an object through which we
can easily identify uniqueness of an object
 Equals : used to compare object based on its content
 Both method present in java.lang.Object class
Interview Q&A
Interview Q&A
9. What is exception and its hierarchy
10. why checked exception also called as compile time exception , is it occurs in
compile time ?
11. How to write custom exception
12. Throw and throws Exception
13. Exception tricky programming question (Exception order)
14. try , catch finally return statement scenario questions
15. is finally block always executed ?
Interview Q&A
16. How many way we can create String object ?
17. String object creation scenario
18. What is SCP and how it works ?
Interview Q&A
19. Why String is immutable
Immutable simply means unmodifiable or unchangeable.
Key points :
 String pool is possible only because String is immutable in Java. This way Java Runtime saves a lot of heap
space because different String variables can refer to the same String variable in the pool.
 If String is not immutable then it would cause a severe security threat to the application. For example,
database username, password are passed as String to get database connection and in socket
programming host and port details passed as String. Since String is immutable, its value can’t be changed
otherwise any hacker could change the referenced value to cause security issues in the application.
 Since String is immutable, it is safe for multithreading. A single String instance can be shared across
different threads. This avoids the use of synchronization for thread safety.
 Since String is immutable, its hashcode is cached at the time of creation and it doesn’t need to be
calculated again. This makes it a great candidate for the key in a Map and its processing is faster than
other HashMap key objects. This is why String is the most widely used as HashMap keys.
Interview Q&A
20. how to use mutable class and what is the difference between StringBuffer
and StringBuilder
Interview Q&A
21. How to write your own custom immutable class
 Make your class final
 Declare all instance variable with private and final
 Say no to setter methods
 Initialize all variables in constructor
 You can initialize variables in constructor
 Perform cloning of mutable objects while returning from getter method
 you can go with clone method but its always not recommended, I will show you its disadvantages
Interview Q&A
22. Which one is good to store password in java String or char[] & Why
Here are a few reasons which make sense to believe that character array is a better choice
for storing the password in Java than String
 Since Strings are immutable in Java if you store the password as plain text it will be
available in memory until the Garbage collector clears it and also String literal is stored
String pool for reusability there is a pretty high chance that it will remain in memory for
long duration
 Because its difficult to destroy literal from SCP as GC unable to perform cleanup activity
in SCP only it will destroy once jvm restarted so which may leads a high security threat
 Since anyone who has access to memory dump can find the password in clear text and
that's another reason you should always use an encrypted password than plain text
Interview Q&A
 Since Strings are immutable there are no way contents of Strings can be changed because
any change will produce new String, while if you char[] you can still set all his elements
as blank or zero. So Storing the password in character array clearly mitigates security
risk of stealing passwords.
 With String there is always a risk of printing plain text in log file or console but if use
Array you won't print contents of array instead its memory location get printed. though
not a real reason but still make sense.
Interview Q&A
23. What is Marker interface (tagging interface) ? Can we create our own
marker interface ?
A marker interface is an interface that has no methods or constants inside it. Java has many
built-in marker interfaces, such as Serializable, Cloneable, and Remote.
It provides run-time type information about objects, so the compiler and JVM have
additional information about the object.
Let's take the example of the Cloneable interface. If we try to clone an object that doesn't
implement this interface, the JVM throws a CloneNotSupportedException. Hence, the
Cloneable marker interface is an indicator to the JVM that we can call the Object.clone()
method.
Interview Q&A

More Related Content

Similar to Interview-QA.pptx

Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answerskavinilavuG
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocksİbrahim Kürce
 
Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with GroovyDhaval Dalal
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1SURBHI SAROHA
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2Sherihan Anver
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introductionchnrketan
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questionsGradeup
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questionssoniajessica2
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questionsSynergisticMedia
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for MainframersRich Helton
 
Java Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming BasicsJava Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming BasicsAkshaj Vadakkath Joshy
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PunePankaj kshirsagar
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and ConcurrencyRajesh Ananda Kumar
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-pptMayank Kumar
 

Similar to Interview-QA.pptx (20)

Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
 
Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with Groovy
 
Java_Interview Qns
Java_Interview QnsJava_Interview Qns
Java_Interview Qns
 
Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1Object-Oriented Programming with Java UNIT 1
Object-Oriented Programming with Java UNIT 1
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
 
What is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK TechnologiesWhat is Java? Presentation On Introduction To Core Java By PSK Technologies
What is Java? Presentation On Introduction To Core Java By PSK Technologies
 
Java_Roadmap.pptx
Java_Roadmap.pptxJava_Roadmap.pptx
Java_Roadmap.pptx
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
 
Core_Java_Interview.pdf
Core_Java_Interview.pdfCore_Java_Interview.pdf
Core_Java_Interview.pdf
 
Java67
Java67Java67
Java67
 
20 most important java programming interview questions
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
 
java notes.pdf
java notes.pdfjava notes.pdf
java notes.pdf
 
Java Interview Questions
Java Interview QuestionsJava Interview Questions
Java Interview Questions
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
 
Java Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming BasicsJava Simplified: Understanding Programming Basics
Java Simplified: Understanding Programming Basics
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council Pune
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
 
Core Java interview questions-ppt
Core Java interview questions-pptCore Java interview questions-ppt
Core Java interview questions-ppt
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Interview-QA.pptx

  • 1.
  • 2. 1. What is the pillar of oops concept Encapsulation Inheritance Polymorphism Abstraction 2. Where did you use this concepts in your project 3. Explain Exception hierarchy in Inheritance 4. parent child override scenario 5. can we override static and private method ? 6. what is the difference of java 7 and java 8 interface Java 8 Default method ,static method Interview Q&A
  • 3. 7. What is final, finally and finalize ?  final : keyword  finally : block  finalize : method 8. What is equals and hashcode method and its contract  Hashcode : used to generate unique or reference number of an object through which we can easily identify uniqueness of an object  Equals : used to compare object based on its content  Both method present in java.lang.Object class Interview Q&A
  • 4. Interview Q&A 9. What is exception and its hierarchy
  • 5. 10. why checked exception also called as compile time exception , is it occurs in compile time ? 11. How to write custom exception 12. Throw and throws Exception 13. Exception tricky programming question (Exception order) 14. try , catch finally return statement scenario questions 15. is finally block always executed ? Interview Q&A
  • 6. 16. How many way we can create String object ? 17. String object creation scenario 18. What is SCP and how it works ? Interview Q&A
  • 7. 19. Why String is immutable Immutable simply means unmodifiable or unchangeable. Key points :  String pool is possible only because String is immutable in Java. This way Java Runtime saves a lot of heap space because different String variables can refer to the same String variable in the pool.  If String is not immutable then it would cause a severe security threat to the application. For example, database username, password are passed as String to get database connection and in socket programming host and port details passed as String. Since String is immutable, its value can’t be changed otherwise any hacker could change the referenced value to cause security issues in the application.  Since String is immutable, it is safe for multithreading. A single String instance can be shared across different threads. This avoids the use of synchronization for thread safety.  Since String is immutable, its hashcode is cached at the time of creation and it doesn’t need to be calculated again. This makes it a great candidate for the key in a Map and its processing is faster than other HashMap key objects. This is why String is the most widely used as HashMap keys. Interview Q&A
  • 8. 20. how to use mutable class and what is the difference between StringBuffer and StringBuilder Interview Q&A
  • 9. 21. How to write your own custom immutable class  Make your class final  Declare all instance variable with private and final  Say no to setter methods  Initialize all variables in constructor  You can initialize variables in constructor  Perform cloning of mutable objects while returning from getter method  you can go with clone method but its always not recommended, I will show you its disadvantages Interview Q&A
  • 10. 22. Which one is good to store password in java String or char[] & Why Here are a few reasons which make sense to believe that character array is a better choice for storing the password in Java than String  Since Strings are immutable in Java if you store the password as plain text it will be available in memory until the Garbage collector clears it and also String literal is stored String pool for reusability there is a pretty high chance that it will remain in memory for long duration  Because its difficult to destroy literal from SCP as GC unable to perform cleanup activity in SCP only it will destroy once jvm restarted so which may leads a high security threat  Since anyone who has access to memory dump can find the password in clear text and that's another reason you should always use an encrypted password than plain text Interview Q&A
  • 11.  Since Strings are immutable there are no way contents of Strings can be changed because any change will produce new String, while if you char[] you can still set all his elements as blank or zero. So Storing the password in character array clearly mitigates security risk of stealing passwords.  With String there is always a risk of printing plain text in log file or console but if use Array you won't print contents of array instead its memory location get printed. though not a real reason but still make sense. Interview Q&A
  • 12. 23. What is Marker interface (tagging interface) ? Can we create our own marker interface ? A marker interface is an interface that has no methods or constants inside it. Java has many built-in marker interfaces, such as Serializable, Cloneable, and Remote. It provides run-time type information about objects, so the compiler and JVM have additional information about the object. Let's take the example of the Cloneable interface. If we try to clone an object that doesn't implement this interface, the JVM throws a CloneNotSupportedException. Hence, the Cloneable marker interface is an indicator to the JVM that we can call the Object.clone() method. Interview Q&A