SlideShare a Scribd company logo
2
Most read
3
Most read
Java Interview Questions and Answers for cognizant:
In this Java Interview Questions, I am going to list some of the most important
Java Interview Questions and Answers which will help you in the interview
process. Java is used by approximately 10 Million developers worldwide to develop
applications. It is also used to create applications for trending technologies like
Mobiles. And hence today, Java is used everywhere!
1. What do you understand by java?
 Java is an object-oriented computer language.
 Java is a fast, secure and reliable languageused for many games, devices
and applications.
2. What are the major Java features?
 Object-Oriented – java is based on object-oriented programming where the class and
methods describe about the state and behaviour of object.
 Portable – Java program gets converted into Java Byte Codes that can be executed
on any platform without any dependency.
 Platform independent – java works on “write once and run anywhere” as it supports
multiple platforms like Windows, Linux, Mac, Sun Solaris, etc.
 Robust – Java has a strong memory management as there is no pointer allocations. It
has automatic garbage collection that prohibits memory leaks.
 Interpreted – java compiler converts the codes into Java Byte Codes which are then
interpreted and executed by Java Interpreter.
2. What doyoumeanby Object?
 A Javaobject is a combinationof data andprocedures workingon the available data.
 Objects are created from templatesknownas classes. InJava, an object is created usingthe
keyword"new".
3. What is class inJava?
 A class is a user defined blueprint or prototype from which objects are created. It
represents the set of properties or methods that are common to all objects of one type.
4. What is JDK, JREand JVM?
 JVM stands for Java Virtual Machine which provides runtime environment for Java
Byte Codes to be executed.
 JRE stands for Java Runtime Environment that includes sets of files required by
JVM during runtime.
 JDK stands for Java Development Kit consists of JRE along with the development
tools required to write and execute a program.
5. Differentiate between String Buffer and String Builder in Java
programming?
 String Buffer in java is used to create modifiable String objects. This means
that we can use String Buffer to append, reverse, replace, concatenate and
manipulate Strings or sequence of characters.
 Java String Builder class is designed for use as a drop-in replacement for String
Buffer in places where the string buffer was being used by a single thread (as
is generally the case).
6. Difference between Array list And Vector?
 An array is nothing but a sequential collection same type of elements, accessed by
their index values.
 Java Array List uses an array as the internal programming construct to store
elements.
 Vectors in java just another kind of object, of type java.util.Vector.
7. Difference between the Inner Class and Sub Class?
 Inner class provides the access rights for the class which is nesting it and that can access all
variables and methods defined in the outer class.
 Sub-class provides access to all public and protected methods and fields of its super class.
8. Name the methods of Object Class?
 clone() – This method helps to create and return a copy of the object.
 equals() – This method helps to compare
 finalize() – Called by the garbage collector on an object
 getClass() – It helps to return the runtime class of an object.
 hashCode() – Helps to return a hash code value for the object.
 toString() – helps to return a string representation of the object.
 notify(), notifyAll(), and wait() – It helps to synchronize the activities of
independently running threads in a program.
9. What are Loops in Java? What are three types of loops?
 Looping is used in programming to execute a statement or a block of
statement repeatedly. There are three types of loops in Java:
1) For Loops
For loops are used in java to execute statements repeatedly for a given number
of times. For loops are used when number of times to execute the statements is
known to programmer.
2) While Loops
While loop is used when certain statements need to be executed repeatedly until
a condition is fulfilled. In while loops, condition is checked first before execution of
statements.
3) Do While Loops
Do While Loop is same as while loop with only differencethat condition is
checked after execution of block of statements. Hence in case of do while loop,
statements are executed at least once.
10. What is Final Keyword in Java? Give an example.
 In java, a constant is declared using the keyword Final. Value can be
assigned only once and after assignment, value of a constant can't be
changed.
In below example, a constant with the name const_val is declared and assigned
avalue:
Private Final int const_val=100 When a method is declared as final,it can NOT be
overridden by the subclasses.This method are faster than any other
method,because they are resolved at complied time.
When a class is declares as final,it cannot be subclassed. Example String,Integer
and other wrapper classes.
Java interview questions and answers for cognizant By Data Council Pune

More Related Content

Similar to Java interview questions and answers for cognizant By Data Council Pune (20)

PPTX
Java interview questions 2
Sherihan Anver
 
DOC
Questions of java
Waseem Wasi
 
PDF
Java interview questions
rithustutorials
 
PPTX
Java For Automation
Abhijeet Dubey
 
DOC
Core java interview questions1
Lahari Reddy
 
PDF
Java Interview Questions
soniajessica2
 
PDF
java-2marks-qzcvhsvnmdjdvjndcsdcuestions-with-answer.pdf
vijaybabu0905
 
PDF
What are the different java interview questions you need to know?
kanchanmahajan23
 
PDF
Top 100 Java Interview Questions with Detailed Answers
Whizlabs
 
PPTX
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
PriyanshuGupta101797
 
DOC
Java interview faq's
Deepak Raj
 
PDF
Java_Question-Bank.docx-1.pdf
Nguyen Huu Thuong
 
DOCX
100 Java questions FOR LOGIC BUILDING SOFTWARE.docx
MaheshRamteke3
 
PPT
Java interview-questions-and-answers
bestonlinetrainers
 
DOCX
What are the different java interview questions you need to know?
kanchanmahajan23
 
PDF
Java interview questions and answers
kavinilavuG
 
PDF
__ Java Technical round questions .pdf soo
Rajkumar751652
 
DOCX
Jist of Java
Nikunj Parekh
 
DOCX
JAVA CONCEPTS AND PRACTICES
Nikunj Parekh
 
PPTX
Java J2EE Interview Questions Part-1
javatrainingonline
 
Java interview questions 2
Sherihan Anver
 
Questions of java
Waseem Wasi
 
Java interview questions
rithustutorials
 
Java For Automation
Abhijeet Dubey
 
Core java interview questions1
Lahari Reddy
 
Java Interview Questions
soniajessica2
 
java-2marks-qzcvhsvnmdjdvjndcsdcuestions-with-answer.pdf
vijaybabu0905
 
What are the different java interview questions you need to know?
kanchanmahajan23
 
Top 100 Java Interview Questions with Detailed Answers
Whizlabs
 
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
PriyanshuGupta101797
 
Java interview faq's
Deepak Raj
 
Java_Question-Bank.docx-1.pdf
Nguyen Huu Thuong
 
100 Java questions FOR LOGIC BUILDING SOFTWARE.docx
MaheshRamteke3
 
Java interview-questions-and-answers
bestonlinetrainers
 
What are the different java interview questions you need to know?
kanchanmahajan23
 
Java interview questions and answers
kavinilavuG
 
__ Java Technical round questions .pdf soo
Rajkumar751652
 
Jist of Java
Nikunj Parekh
 
JAVA CONCEPTS AND PRACTICES
Nikunj Parekh
 
Java J2EE Interview Questions Part-1
javatrainingonline
 

Recently uploaded (20)

PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Geographical Diversity of India 100 Mcq.pdf/ 7th class new ncert /Social/Samy...
Sandeep Swamy
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Ad

Java interview questions and answers for cognizant By Data Council Pune

  • 1. Java Interview Questions and Answers for cognizant: In this Java Interview Questions, I am going to list some of the most important Java Interview Questions and Answers which will help you in the interview process. Java is used by approximately 10 Million developers worldwide to develop applications. It is also used to create applications for trending technologies like Mobiles. And hence today, Java is used everywhere! 1. What do you understand by java?  Java is an object-oriented computer language.  Java is a fast, secure and reliable languageused for many games, devices and applications. 2. What are the major Java features?  Object-Oriented – java is based on object-oriented programming where the class and methods describe about the state and behaviour of object.  Portable – Java program gets converted into Java Byte Codes that can be executed on any platform without any dependency.  Platform independent – java works on “write once and run anywhere” as it supports multiple platforms like Windows, Linux, Mac, Sun Solaris, etc.  Robust – Java has a strong memory management as there is no pointer allocations. It has automatic garbage collection that prohibits memory leaks.  Interpreted – java compiler converts the codes into Java Byte Codes which are then interpreted and executed by Java Interpreter. 2. What doyoumeanby Object?  A Javaobject is a combinationof data andprocedures workingon the available data.  Objects are created from templatesknownas classes. InJava, an object is created usingthe keyword"new". 3. What is class inJava?  A class is a user defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type. 4. What is JDK, JREand JVM?  JVM stands for Java Virtual Machine which provides runtime environment for Java Byte Codes to be executed.
  • 2.  JRE stands for Java Runtime Environment that includes sets of files required by JVM during runtime.  JDK stands for Java Development Kit consists of JRE along with the development tools required to write and execute a program. 5. Differentiate between String Buffer and String Builder in Java programming?  String Buffer in java is used to create modifiable String objects. This means that we can use String Buffer to append, reverse, replace, concatenate and manipulate Strings or sequence of characters.  Java String Builder class is designed for use as a drop-in replacement for String Buffer in places where the string buffer was being used by a single thread (as is generally the case). 6. Difference between Array list And Vector?  An array is nothing but a sequential collection same type of elements, accessed by their index values.  Java Array List uses an array as the internal programming construct to store elements.  Vectors in java just another kind of object, of type java.util.Vector. 7. Difference between the Inner Class and Sub Class?  Inner class provides the access rights for the class which is nesting it and that can access all variables and methods defined in the outer class.  Sub-class provides access to all public and protected methods and fields of its super class. 8. Name the methods of Object Class?  clone() – This method helps to create and return a copy of the object.  equals() – This method helps to compare  finalize() – Called by the garbage collector on an object  getClass() – It helps to return the runtime class of an object.  hashCode() – Helps to return a hash code value for the object.  toString() – helps to return a string representation of the object.  notify(), notifyAll(), and wait() – It helps to synchronize the activities of independently running threads in a program. 9. What are Loops in Java? What are three types of loops?  Looping is used in programming to execute a statement or a block of statement repeatedly. There are three types of loops in Java:
  • 3. 1) For Loops For loops are used in java to execute statements repeatedly for a given number of times. For loops are used when number of times to execute the statements is known to programmer. 2) While Loops While loop is used when certain statements need to be executed repeatedly until a condition is fulfilled. In while loops, condition is checked first before execution of statements. 3) Do While Loops Do While Loop is same as while loop with only differencethat condition is checked after execution of block of statements. Hence in case of do while loop, statements are executed at least once. 10. What is Final Keyword in Java? Give an example.  In java, a constant is declared using the keyword Final. Value can be assigned only once and after assignment, value of a constant can't be changed. In below example, a constant with the name const_val is declared and assigned avalue: Private Final int const_val=100 When a method is declared as final,it can NOT be overridden by the subclasses.This method are faster than any other method,because they are resolved at complied time. When a class is declares as final,it cannot be subclassed. Example String,Integer and other wrapper classes.