[Go to site: main page, start]

0% found this document useful (0 votes)
7 views16 pages

Comprehensive Java OOPs and Concepts Guide

Uploaded by

suresh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views16 pages

Comprehensive Java OOPs and Concepts Guide

Uploaded by

suresh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Questions TopicWise JAVA

OOPs

Q.1 What do you mean by Inheritance ? What are the


advantages of Inheritance ?

Q.2 Which class is by default parent class of all java classes ?


why ?

Q.3 How many types of Inheritance are possible explain each


and which type of Inheritance not supported in java ?

Q.4 What do you mean by multiple Inheritance ?

Q.5 Why java doesn’t support multiple inheritance?

Q.6 What is an ambiguity problem or diamond problem


regarding inheritance in java ?

Q.7 Why does the ambiguity problem not arise in the case of
interfaces in java ?

Q.8 What do you mean by a HAS-A relationship ?

Q.9 What do you mean by composition and aggregation in


JAVA ?

Q.10 Give practical example of composition and aggregation in


JAVA ?

Q. 11 What do you mean by method signature ?


Q.12 What do you mean by method overloading ?

Q. 13 What do you mean by method overriding ?

Q. 14 What do you mean by method hiding ?

Q. 15 Explain the differences between method overriding and


method hiding in java ?

Q. 16 Explain the differences between method overloading and


method overriding in java ?

Q. 17 What do you mean by polymorphism ? How many types


of polymorphism are there ?

Q.20 What is the main purpose of the Constructor ?

Q. 23 What do you mean by default constructor ?

Q. 24 What are the differences between super(), this() and


super,this ?

Q. 26 What do you mean by object type casting ?

Q. 27 Explain rules for object type casting ?

Q.28 What do you mean by Data hiding, Abstraction,


Encapsulation in Java ?

Q.29 What is the purpose of the static block ?

Q.30 What is the purpose of the instance block ?

Q.31 What do you mean by coupling ?


Q.32 What do you mean by Cohesion ?
Language Fundamentals

Q.1 What do you mean by Identifiers ?

Q.2 Explain Rules of Java Identifiers ?

Q.3 Difference between float and double data type ?

Q.4 Why char data types takes 2 byte of memory in java ?

Q.5 What are the advantages and disadvantages of array ?

Q.7 What are the differences between instance and static


variables ?

Q.8 What do you mean by the var-arg method ?

Q.9 What are the advantages of the var-arg method ?

Q.10 What changes can we perform on main() ?

Q.12 What do you mean by command line arguments ?


Exception Handling

Q.1 What do you mean by exception ?

Q.2 What is the main objective of Exception Handling ?

Q.3 What is the meaning of Exception Handling ?

Q.5 Which is the root class for Java Exception Hierarchy and
why ?

Q.6 What are the differences between checked exceptions &


unchecked exceptions ?

Q.7 What are the differences between partially checked


exceptions & fully checked exceptions ?

Q.8 What is the purpose of try and catch block ?

Q.9 Explain about methods to print exception information to


the console ?

Q.10 What is the main purpose of try with multiple catch


blocks ?

Q.11 What is the main purpose and speciality of finally block ?

Q.13 What is the purpose of the throw keyword ?

Q.14 What is the purpose of the throws keyword ?

Q.15 How many types of exceptions are available in java ?

Q.16 Explain any 5 exceptions of java ?


Declaration & Access Modifiers

Q.1 How many classes a java program can contain ?

Q.2 What do you mean by fully qualified name and what is the
problem in using a fully qualified name ?

Q.3 What is the purpose of import ?

Q.4 Explain types of import statement ?

Q.6 What do you mean by static import ?

Q. 7 What are the advantages and disadvantages of using


static import ?

Q.8 What do you mean by package ?

Q.9 What do you mean by public modifier ?

Q.10 What do you mean by private modifier ?

Q.11 What do you mean by <default> modifier ?

Q.12 What do you mean by protected modifier ?

Q.13 What do you mean by final modifier ?

Q.14 Explain abstract class and abstract method ?

Q.15 What is the purpose of strictfp modifier ?


Q.16 What is the purpose of native modifier ?

Q.17 How many modifiers are applicable on outer class ?

Q.18 Which modifiers are applicable for local variables ?

Q.19 Which modifiers are applicable only for method ?

Q.20 Which modifiers are applicable only for variables ?

Q.21 On Constructors which modifiers are applicable?


Interface

Q.1 What do you mean by interface ?

Q.2 Explain about extends and implements keywords ?

Q.3 What is the purpose of import ?

Q.4 Explain about interface methods and interface variables ?

Q.5 Multiple Inheritance possible in java or not ?

Q.6 Why is multiple Inheritance not supported in classes but


supported in Interfaces ?

Q.7 How many Interfaces a Java class can implement


simultaneously ?

Q.8 What do you mean by marker Interface ?

Q.9 What do you mean by Adapter class ?

Q.10 What are the differences between abstract class &


Interface ?

Q.11 What do you mean by default method in Interface ?

Q.12 What do you mean by static method in Interface ?


[Link] package
Q.1 Explain about Object class?

Q.2 Explain about toString() ?

Q.3 What do you mean by hashCode ?

Q.4 Explain about equals() ?

Q.5 Explain the relation between == operator and equals() ?

Q.6 What are the differences between == operator and equals()


?

Q.7 What is the purpose of cloning ?

Q.8 What are the differences between shallow cloning and


deep cloning ?

Q.9 What are the differences between String and StringBuffer ?

Q.10 Why is the String class object immutable ?

Q.11 What are the advantages and disadvantages of scp ?

Q.12 What are the differences between equals() and


equalsIgnoreCase() ?

Q.13 What are the differences between StringBuffer and


StringBuilder ?

Q.14 What do you mean by wrapper classes ?


Q.15 Which wrapper classes are not direct child classes of the
Object class ?

Q.16 Which wrapper classes are direct child classes of the


Object class ?

Q.17 What do you mean by auto boxing & auto unboxing ?


Garbage Collection
Q.1 What do you mean by Garbage Collection ?

Q.2 When an object is said to be eligible for GC ?

Q.3 Explain ways to make an object eligible for GC ?

Q.4 How can we request JVM to run GC ?

Q.5 Explain the purpose of finalize() ?

Q.6 What do you mean by memory leaks ?


Collection Framework
Q.1 What are the advantages and disadvantages of array ?

Q.2 What are the advantages of collection ?

Q.3 What are the differences between array & collection ?

Q.4 What are the differences between add() and addAll()


method of Collection interface ?

Q.5 What is the purpose of retainAll() of Collection interface ?

Q.6 What are the differences between contains() and


containsAll() method of Collection interface ?

Q.7 What are the differences between Collection & Collections


?

Q.8 Explain the properties of ArrayList ?

Q.9 What is the relation between current capacity & new


capacity of ArrayList ?

Q.10 What are the differences between ArrayList & Vector ?

Q.11 When ArrayList is the best choice ?

Q.12 Explain the properties of LinkedList ?

Q.13 When LinkedList is the best choice ?

Q.14 Explain the properties of Vector ?


Q.15 Explain the properties of Stack ?

Q.16 What are the differences between pop() and peek() of


Stack class ?

Q.17 What do you mean by cursors & how many cursors are
available in Java ?

Q.18 Explain the properties of the Enumeration cursor ?

Q.19 What are the limitations of the Enumeration cursor ?

Q.20 Explain the properties of the Iterator cursor ?

Q.21 What are the limitations of the Iterator cursor ?

Q.22 Explain the properties of the Listterator cursor ?

Q.23 What are the limitations of the ListIterator cursor ?

Q.24 What are the differences among all the 3 cursors ?

Q.25 Explain the properties of HashSet ?

Q.27 What are the differences between HashSet &


LinkedHashSet ?

Q.28 Explain the properties of TreeSet ?

Q.29 What are the differences between Comparable &


Comparator ?

Q.30 What is the purpose of the Map interface ?

Q.32 Explain the properties of HashMap ?


Q.33 What are the differences between HashMap & Hashtable ?

Q.34 What are the differences between HashMap &


LinkedHashMap ?

Q.35 What are the differences between HashMap &


IdentityHashMap ?

Q.36 What are the differences between HashMap &


WeakHashMap ?

Q.37 Explain the properties of TreeMap ?

Q.38 What is the main purpose of Generics ?

Q.39 What are the differences between ArrayList l=new


ArrayList() and ArrayList<String> l=new ArrayList<String>() ?
Multi-Threading
Q.1 What do you mean by Multi-Tasking ?

Q.2 What are the differences between process based


multitasking and thread based multitasking ?

Q.3 By How many ways can we create a Thread in Java ?

Q.4 What do you mean by Thread Scheduler ?

Q.5 What are the differences between [Link]() & [Link]() ?

Q.6 What is the importance of Thread class start() ?

Q.9 Explain Thread life cycle in Java ?

Q.10 How can we set and get the name of a thread in Java ?

Q.11 How can we get current executing thread object in Java ?

Q.12 What do you mean by Thread Priority In Java ?

Q.13 Explain the concept of default priority ?

Q.14 Explain the purpose of yield() ?

Q.15 Explain the purpose of join() ?

Q.16 Explain the purpose of sleep() ?

Q.17 What do you mean by synchronization ?


Q.18 What are the advantages & disadvantages of
synchronization ?

Q.19 What do you mean by object level lock ?

Q.21 What is the purpose of synchronized block ?

Q.22 What do you mean by daemon thread ?

Q.23 What is the default daemon nature ?

Q.24 What do you mean by Inter Thread Communication ?

Q.25 What is the difference between notify() and notifyAll() ?

Q.26 What do you mean by deadlock ?

Q.27 What are the differences between deadlock & starvation ?

Common questions

Powered by AI

ArrayList and LinkedList are both part of the Java Collection Framework but have differing implementations and use-cases. ArrayList uses a dynamic array to store elements and is preferable for retrieving data quickly due to direct access via index. In contrast, LinkedList consists of nodes where each node contains a reference to the next, making it suitable for scenarios involving frequent insertions and deletions within the list. However, access time in LinkedList is slower because it requires traversal from the start of the list .

Java implements polymorphism primarily in two types: compile-time (or static) and runtime (or dynamic) polymorphism. Compile-time polymorphism is achieved through method overloading, where methods have the same name but different parameter lists or types within a class. Runtime polymorphism is achieved via method overriding, where a subclass provides specific implementations of methods declared in a parent class. These approaches allow Java programs to adapt behaviors at runtime, leading to more flexible and reusable code structures .

The 'super()' keyword in Java is used to refer to the immediate parent class object. It is employed within a subclass constructor to invoke the constructor of the parent class. This invocation helps to avoid code duplication and facilitates the initialization of parent class members before executing the subclass code. It is crucial in the context of inheritance and providing an extended class with a proper initialization chain .

Java resolves the ambiguity problems of multiple inheritance in interfaces by allowing classes to implement multiple interfaces. When a class implements multiple interfaces that contain methods with the same name, the implementing class must either provide its own implementation or inherit a default method, if defined. This design ensures there is no conflict between method definitions, which effectively handles ambiguity issues .

Checked exceptions in Java are those that must be declared in a method's or constructor's 'throws' clause if they can be thrown by the execution of the method or constructor and propagated outside the method or constructor boundary. Examples include IOException and SQLException. Unchecked exceptions, derived from RuntimeException, are not subject to compile time inspection, meaning they do not need to be explicitly addressed, such as ArithmeticException and NullPointerException. This distinction ensures that part of the error handling is enforced for critical exceptions .

Garbage collection in Java is a process by which the Java Virtual Machine (JVM) automatically removes objects that are no longer reachable, thereby reclaiming memory resources. An object becomes eligible for garbage collection when it is no longer accessible through any reference chain, such as when an object's reference is set to null, or it falls out of scope. Developers can suggest the JVM run the garbage collector using System.gc(), though it is not guaranteed it will execute immediately .

Strings in Java are immutable for several reasons: security, synchronization, and performance. Immutability ensures that once a string object is created, it cannot be modified, thereby guaranteeing its integrity and reducing errors due to shared references in multi-threaded environments. It also improves performance, especially in applications that require a lot of string manipulation, because Java can optimize the handling of immutable string objects, such as caching string literals. This design decision helps avoid potential security pitfalls and simplifies string handling .

Generics in Java provide a way to enforce type safety at compile time, allowing developers to specify what types of objects a collection can hold. This significantly reduces the risks of ClassCastException, allowing for more readable and robust code by eliminating the need for explicit casting. Generics also enable developers to implement algorithms that work on collections of various types, increasing code reusability .

Multiple inheritance refers to a class inheriting from more than one class. Java does not support multiple inheritance for classes to avoid complexity and ambiguity, often referred to as the "diamond problem," which arises when two classes inherit from the same base class, causing confusion over which implementation is inherited. Instead, Java uses interfaces to enable a similar functionality that avoids these issues, as interfaces provide a way to achieve multiple inheritance without ambiguity .

Method overloading occurs when multiple methods have the same name but different parameter lists within the same class. It is a compile-time polymorphism. Method overriding, however, happens when a subclass provides a specific implementation for a method already defined in its superclass, adhering to the same signature, and is a runtime polymorphism. The primary goal of method overloading is to enhance readability and usability, while method overriding is used to achieve dynamic polymorphism and allow a subclass to tailor inherited behavior .

You might also like