JAVA Viva Prep
JAVA Viva Prep
1. What is object oriented programming? How is this different from procedural programing?
2. What is an object in OOP?
3. What are the properties of an object? Give an example.
4. What is a class? What are the differences between a class and an object?
5. What is abstraction in OOP?
6. What is encapsulation? How do we encapsulate an attribute in java? Can we encapsulate a
method?
7. How many data types are there in Java?
8. What is instantiation? How to create an instance of an object in Java?
SLIDE 2 – USING OBJECTS
1. What is an object reference? Give an example. What is the difference between object
reference and instance?
2. How do we invoke a method in OOP?
3. What happens when you assign a variable to another variable in JAVA?
4. What are aliases? Provide an example.
5. What is the garbage collector in JAVA? How does it help?
6. What is a library? Give some examples. How to import a library in JAVA? What library is
imported by default in JAVA?
7. What is a package?
8. Describe the 'Random' class in java. For what we can use it? Give an example.
9. What is the 'Scanner' class?
10. Describe the 'Math' class.
11. How can we take user input in JAVA?
12. How to output something in JAVA?
SLIDE 3 – Writing Classes
1. What is a constructor? How many constructors can a class have? What happens if there is
no constructor in a class? Will there be an error when the code is executed?
2. What are the accessors and mutators?
3. What is the toString method?
4. What is an UML diagram?
5. How many visibility modifiers are there in JAVA? What are they?
SLIDE 4 – Object Oriented Design
1. What are steps involved in the creation of a software? Describe each steps.
2. What is a static method? What is a static variable?
3. How many class relationship exists? Describe each of them with an example.
4. How to use an object as a method parameter?
SLIDE 5 – ArrayList
1. What is an ArrayList? What are the differences between Array and ArrayList? Which is
better and why?
2. Which library in JAVA contains the ArrayList class?
3. How to declare an ArrayList?
4. ArrayList<int> list. Is this valid? If not, why?
5. If we write, new ArrayList<>(10), what does this 10 indicates?
6. How to add something into an ArrayList? How to insert in between?
7. How to get the data from ith index?
8. How to find how many items are there in an ArrayList?
9. How to change the value of 4th index of an ArrayList to 27?
10. How to delete an element from an ArrayList?
11. How to remove all elements from an ArrayList at once?
12. How to search for an item in an ArrayList?
13. How to get the index of an element in an ArrayList? What will happen if the value isn’t
present in the ArrayList?
14. How to check if an ArrayList has any element or not?
15. How does a for-each loop works? Is it better than a for loop?
16. How can we copy an ArrayList?
SLIDE 6 – Inheritance
1. What is polymorphism?
3. What is an interface?
8. Name any interface that is already built-in JAVA. What does this interface do?
SLIDE 9 - Exceptions
1. What is an exception?
1. What is SWING?
2. What is components/widgets in SWING?
3. Name some types of layouts in SWING.
4. Which SWING component we use to take user input?
5. How can we upload a file in SWING?
6. What is an event?
7. How can we handle an event in SWING?
SLIDE 11 – Streams and File I/O