Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
16 views
Viva Oopj
Viva questions for object oriented programming with java
Uploaded by
luckysuranasahada
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save VIVA OOPJ For Later
Download
Save
Save VIVA OOPJ For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
16 views
Viva Oopj
Viva questions for object oriented programming with java
Uploaded by
luckysuranasahada
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save VIVA OOPJ For Later
Carousel Previous
Carousel Next
Save
Save VIVA OOPJ For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 9
Search
Fullscreen
Batthula Manoj PIET CSE Al Viva Questions Oops 4. Introduction to Java 1.What is Java, and why is it platform-independent? Java is a high-level, object-oriented programming language. It's platform-independent because its code is compiled into bytecode, which can run on any machine with a JVM (Java Virtual Machine). 2 What is the difference between JVM, JRE, and JDK? JVM (Java Virtual Machine) runs Java bytecode, JRE (Java Runtime Environment) provides libraries and JVM, and JDK (Java Development Kit) is a complete development kit, including JRE and development tools. ‘3.What is bytecode in Java? Bytecode is the intermediate code generated after Java source code is compiled. It's platform-independent and executed by the JVM. 2. Control Statements 4.What are the types of control statements in Java? Control statements include conditional (iFelse, switch), looping (for, while, do-while), and branching (break, continue, return) ‘5. What is the difference between while and do-while loops? In while, the condition is checked before the loop execution, while in do-while, the loop executes at least once before checking the condition. 6.What does the break statement do? It terminates the loop or switch statement immediately. 3. Inheritance 7.What is inheritance in Java? Inheritance allows one class (child) to acquire properties and behaviors (methods) of another class (parent) ‘8. What is method overriding?‘Method overriding occurs when a subclass provides a specific implementation of a method that is already defined in its superclass. ‘9. How is multiple inheritance achieved in Java? ‘Muttiple inheritance is not directly supported with classes but can be achieved using interfaces. 4. Strings 10.How are strings immutable in Java? Once a String object is created, its value cannot be changed. If modified, a new object is created instead. 11 What is the difference between String, StringBuilder, and StringBuffer? String is immutable, while StringBuilder and StringBuffer are mutable. StringBuffer is thread-safe, whereas StringBuilder is not. 12.How can you compare two strings in Java? You can compare strings using equals() for content comparison of reference comparison. 5. Interface 13.What is an interface in Java? An interface is a reference type in Java that can contain abstract methods and constants. It's used to achieve abstraction and multiple inheritance. 14.How is an interface different from an abstract class? An abstract class can have both abstract and concrete methods, while an interface only contains abstract methods (Java 8+ allows default methods) 15.Can an interface extend another interface? Yes, an interface can extend multiple other interfaces. 6. Multi i 16.What is a thread in Java? A thread is a lightweight subprocess, and Java supports multithreading to execute multiple tasks concurrently. 17 How do you create a thread in Java? A thread can be created by extending the Thread class or by implementing the Runnable interface.18.What is synchronization in Java? ‘Synchronization is used to control the access of multiple threads to shared resources, preventing data inconsistency. 7. Aways 19.What is an array in Java? An array is a collection of elements of the same type, stored in a contiguous memory location. 20.How do you deciare and initialize an array? int{] arr = new int{5}; (declaration and initialization with size) or int] arr initialization) 1, 2, 3}: (direct 21. What is an ArrayindexOutOfBoundsException? This exception occurs when you try to access an array element using an invalid index. 8. Collections 22.What is the Java Collections Framework? It is a set of classes and interfaces that implement commonly reusable collection data structures like List, Set, and Map. 23.What is the difference between ArrayList and LinkedList? ArrayList provides fast random access but slow insertions and deletions, while LinkedList provides faster insertions and deletions but slower random access 24,What is the difference between HashSet and TreeSet? HashSet stores elements in an unordered way, while TreeSet stores them in a sorted (natural order) manner. 25.What is Encapsulation ? Encapsulation is the bundling of data (variables) and methods (functions) that operate on the data into a single unit, ie., a class. it also restricts direct access to some of the object's ‘components, which is known as data hiding Example: You can make fields private and provide public getter and setter methods to access and update the value. class Person { private String name; // Encapsulation: private variablepublic String getNameQ) { // Getter method return name; } public void setName(String name) { // Setter method this.name = name: } } 26. What is Abstraction ? Definition: Abstraction means hiding complex implementation details and showing only the necessary functionality. it allows you to focus on what an object does rather than how it does it Example: Using abstract classes and interfaces to define methods without implementing them. abstract class Animal { abstract void sound(); I! Abstract method, no implementation } class Dog extends Animal { void sound() { ‘System.out printin("Bark’); } } 27. What is inheritance 7 Definition: inheritance is the mechanism by which one class (child or subclass) inherits fields and methods from another class (parent or superclass). This allows for code reusability and establishing relationships between classes. Example ‘A Dog class can inherit properties and behaviors from an Animal class. class Animal { void eat) { System.out printin("Animal is eating’); } }class Dog extends Animal { void bark() { System out printin(’Dog is barking"); } } 28. What is Polymorphism ? Definition: Polymorphism allows one entity (method or object) to take many forms. itis achieved through method overloading (compile-time) and method overriding (run-time) Example ‘Method Overioading (compile-time polymorphism) ~ same method name, different parameters. class Caloulator { int add(int a, int b) { return a +b; } int add(int a, int b, int c) { retuna +b +c; } } Method Overriding (run-time polymorphism) — a subclass provides its own implementation of a method already defined in the parent class. class Animal { void sound() { ‘System.out printin("Animal sound”); } } class Cat extends Animal { void sound() { ‘System.out printin("Meow’); } } 29, Explain about the Association, Aggregation, and Composition ?Association’ |t defines a relationship between two classes where objects of one class interact with objects of another class. For example, a Teacher and a Student class have an association, as a teacher can teach students. Aggregation: \t's a special form of association where one class (whole) contains objects of another class (part). The part can exist independently of the whole. For example, a Department and a Professor—a department can have many professors, but professors can exist independently of the department Composition: It's a stronger form of aggregation where the part cannot exist without the whole. For example, a Car and its Engine—if the car is destroyed, the engine ceases to exist as well 30. What are the four pillars of oops? © Encapsulation © inheritance © polymorphism = Abstraction Allthe best....dp@OOPJ Java Quick Revision 1, Basic Concepts of OOP: - Class: Blueprint for objects, defines attributes and methods. - Object: Instance of a class. - Inheritance: Acquiring properties of one class by another. - Polymorphism: Ability to take many forms (method overloading, method overriding). - Abstraction: Hiding internal details and showing functionality. - Encapsulation: Wrapping data (variables) and methods together as a single unit (class). 2. Principles of OOP in Java: - Encapsulation: Using ‘private’ access specifiers with getter and setter methods. - Inheritance: Using ‘extends’ keyword. A child class inherits from a parent class. - Polymorphism: - Compile-time (Method Overloading): Methods with the same name but different parameter lists - Runtime (Method Overriding): Subclass provides a specific implementation of a method already defined in the parent class - Abstraction: Using abstract classes or interfaces. 3. Key Java Concepts: - Constructor: A special method to initialize objects. No return type, same name as the class. - Static: A keyword for class-level variables or methods that can be accessed without an object - Final: Used to restrict inheritance (class), method overriding, or changing variables - Interface vs Abstract Class: - Interface: All methods are abstract (Java 7). Multiple inheritance possible.- Abstract Class: Can have both abstract and concrete methods. Single inheritance. 4, Access Specitiers: - private: Only within the class. - default: Accessible within the package. - protected: Within the package and by subclasses. - public: Accessible everywhere. 5, Exception Handling: = try-catch block: Used to handle runtime errors (exceptions). - finally block: Executes regardless of an exception, - throw: Used to throw exceptions explicitly - throws: Used in method declarations to specify exceptions that the method can throw. 6. Java Collections Framework: - List: An ordered collection (can contain duplicates). Examples: ArrayList, LinkedList - Set: A collection that cannot contain duplicate elements. Examples: HashSet, TreeSet. - Map: A collection that maps keys to values (no duplicate keys). Examples: HashMap, TreeMap. 7. Threads: - Implemented through: - Extending Thread Class - Implementing Runnable Interface - Use ‘start()' to begin a thread and ‘run()' for its task. - Synchronization: Used to handle concurrency issues.8. File Handling: - FileReader/FileWriter: For reading/writing text files. - BufferedReader/BufferedWriter: For efficient reading/writing. - Serialization: Converting an object into a byte stream for storage or transfer. 9, JVM (Java Virtual Machine): - Responsible for running Java bytecode. Comprises: - Class Loader: Loads class files. - Memory Areas: Heap, Stack, Method Area, etc. - Execution Engine: Executes bytecode 10. Garbage Collection: - Automatic memory management. The garbage collector removes objects that are no longer referenced - You can suggest garbage collection using ‘System.gc()’, but it's not guaranteed to run immediately.
You might also like
Untitled Document
PDF
No ratings yet
Untitled Document
6 pages
OOPS With Java Important Questions For End Sem
PDF
No ratings yet
OOPS With Java Important Questions For End Sem
34 pages
Activity12-16-24
PDF
No ratings yet
Activity12-16-24
5 pages
UNIT WISE 1 MARK QUESTION AND ANSWERS
PDF
No ratings yet
UNIT WISE 1 MARK QUESTION AND ANSWERS
14 pages
Java Viva
PDF
No ratings yet
Java Viva
6 pages
Top 50 Most Frequent Java Interview Questions & Answer
PDF
No ratings yet
Top 50 Most Frequent Java Interview Questions & Answer
24 pages
question and answer
PDF
No ratings yet
question and answer
28 pages
Interview Questions On JAVA
PDF
No ratings yet
Interview Questions On JAVA
32 pages
Core Java Interview Ques
PDF
No ratings yet
Core Java Interview Ques
3 pages
Technical Interview Qns & Ans Blueprint
PDF
No ratings yet
Technical Interview Qns & Ans Blueprint
44 pages
Java_InterviewQuestion_LinkedIn_JavaCommunity
PDF
No ratings yet
Java_InterviewQuestion_LinkedIn_JavaCommunity
45 pages
JAVA OOPS Cheatsheet
PDF
No ratings yet
JAVA OOPS Cheatsheet
19 pages
Eswar Java Interview Questions Answers
PDF
No ratings yet
Eswar Java Interview Questions Answers
40 pages
NIMAP INTERVIEW
PDF
No ratings yet
NIMAP INTERVIEW
13 pages
Java Q&A Notes-1
PDF
No ratings yet
Java Q&A Notes-1
37 pages
Java Interview Questions
PDF
No ratings yet
Java Interview Questions
5 pages
Java
PDF
No ratings yet
Java
53 pages
Java IQ
PDF
No ratings yet
Java IQ
51 pages
Java 70 Sheet
PDF
No ratings yet
Java 70 Sheet
26 pages
JAVA_VIVA_QA
PDF
No ratings yet
JAVA_VIVA_QA
8 pages
Java unit 1
PDF
No ratings yet
Java unit 1
9 pages
Java Interview Questions - Answers
PDF
No ratings yet
Java Interview Questions - Answers
4 pages
Latest Java Interview Question and Answers
PDF
No ratings yet
Latest Java Interview Question and Answers
8 pages
Java_Questions_Answers
PDF
No ratings yet
Java_Questions_Answers
6 pages
JAVA Hand Book
PDF
No ratings yet
JAVA Hand Book
7 pages
Java Interview Imp Questions
PDF
No ratings yet
Java Interview Imp Questions
24 pages
Java
PDF
No ratings yet
Java
2 pages
JAVA Interview Questions
PDF
No ratings yet
JAVA Interview Questions
6 pages
Java Viva Questions - Coders Lodge
PDF
100% (1)
Java Viva Questions - Coders Lodge
15 pages
Beginner Level Java Viva or Interview Questions
PDF
No ratings yet
Beginner Level Java Viva or Interview Questions
13 pages
Java Basic FAQS
PDF
No ratings yet
Java Basic FAQS
32 pages
Java basic Interview Question and Answer for Fresher
PDF
No ratings yet
Java basic Interview Question and Answer for Fresher
5 pages
Screenshot 2023-05-18 at 12.52.17 PM
PDF
No ratings yet
Screenshot 2023-05-18 at 12.52.17 PM
39 pages
Java Interview QUESTIONS
PDF
No ratings yet
Java Interview QUESTIONS
10 pages
Java 5marks Imp Questions
PDF
No ratings yet
Java 5marks Imp Questions
28 pages
Programming in Java
PDF
No ratings yet
Programming in Java
5 pages
Oop 1712341734
PDF
No ratings yet
Oop 1712341734
30 pages
Java Mock Interview Questions
PDF
100% (1)
Java Mock Interview Questions
7 pages
Top 50 Java QnA
PDF
No ratings yet
Top 50 Java QnA
10 pages
Basic Java Interview Questions
PDF
No ratings yet
Basic Java Interview Questions
10 pages
OO Thinking - Interview Questions: 1. What Is Object Oriented Programming?
PDF
100% (1)
OO Thinking - Interview Questions: 1. What Is Object Oriented Programming?
9 pages
Top 34 Java Basic Interview Question Answers
PDF
No ratings yet
Top 34 Java Basic Interview Question Answers
7 pages
Java Interview Questions(1)
PDF
No ratings yet
Java Interview Questions(1)
5 pages
Java Interview Questions For Freshers
PDF
No ratings yet
Java Interview Questions For Freshers
10 pages
Detailed_Java_Concepts
PDF
No ratings yet
Detailed_Java_Concepts
8 pages
2 MARK JAVA
PDF
No ratings yet
2 MARK JAVA
41 pages
Internal Assessment 1
PDF
No ratings yet
Internal Assessment 1
5 pages
503_CA
PDF
No ratings yet
503_CA
41 pages
Core Java 100 Interview Que
PDF
No ratings yet
Core Java 100 Interview Que
41 pages
Java Interview Questions!!
PDF
No ratings yet
Java Interview Questions!!
16 pages
Java_OOPS_Viva_Questions_with_Answers
PDF
No ratings yet
Java_OOPS_Viva_Questions_with_Answers
6 pages
Java Interview Questions With Answers
PDF
No ratings yet
Java Interview Questions With Answers
14 pages
Java Interview
PDF
No ratings yet
Java Interview
82 pages
cs 3 sem answers01
PDF
No ratings yet
cs 3 sem answers01
19 pages
W
PDF
No ratings yet
W
7 pages
Java Interview-1
PDF
No ratings yet
Java Interview-1
9 pages
Java Interview Questions
PDF
No ratings yet
Java Interview Questions
8 pages
JAVA Programming
PDF
No ratings yet
JAVA Programming
7 pages