Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

java

Uploaded by

Onish's
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

java

Uploaded by

Onish's
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

1)What is java

-high level, oop lang -platform independent (run on any device with a jvm)

2)What are the differences between JDK, JRE, and JVM?


-JDK is used to develop java applications and it includes the JRE and development
tools.
-JrE gives an environment to run java applications, includes JVM and also libraries
-JVM provides a runtime environment for executing java bytecode, translates
bytecode to machine code

3)What are the features of Java?


-platform independence, oop, strong type checking, automatic memory management

4)Explain the main principles of object-oriented programming (OOP) and how they
apply to Java.
- main principles of OOP are encapsulation, inheritance, and polymorphism
- implemented through classes, objects, inheritance, polymorphism, abstraction, and
encapsulation.

5)What is the difference between abstract classes and interfaces?


- Abstract classes can have abstract and concrete methods
- interfaces can only have abstract methods. A class can implement multiple
interfaces but can only extend one abstract class.

6)What is the significance of the main method in Java?


-it is the entry point for Java applications. Jvm starts executing the program in
main

7)Explain the concept of multithreading in Java and how it differs from


multitasking.
-It allows multiple threads of execution to run concurrently within a single
process
-MULTITASKING involves running multiple processes concurrently on a computer
system.]

8)What is the difference between ArrayList and LinkedList?


- ArrayList: Implements a dynamic array that can grow or shrink in size. Provides
fast access to elements but slower insertion and deletion operations.
- LinkedList: Implements a doubly linked list. Provides fast insertion and deletion
operations but slower access to elements.

9)How does exception handling work in Java?


Java uses try-catch blocks to handle exceptions. Code that might throw an exception
is placed inside a try block, and the corresponding catch block catches and handles
the exception.

10)What are the different types of exceptions in Java?


-2 types checked exceptions and unchecked exceptions
- Checked exceptions must be caught or declared in the method signature, while
unchecked exceptions do not need to be explicitly handled.

11)Explain the concept of method overloading and method overriding.


- Method overloading, allows a class to have multiple methods with the same name
but different parameters. methods must differ either in the number of parameters or
in the data types of the parameters.
-Method overriding, when a subclass provides a specific implementation of a method
that is already defined in its superclass. In this the method signatures must be
identical, (including the name, return type, and parameters.)
12)What is the difference between static and non-static methods?
-Static methods belong to the class rather than any instance of the class. They can
be called without creating an instance of the class and cannot access instance
variables directly.
-Whereas non-static methods belong to the instance of the class. They can access
both static and non-static members of the class and require an instance of the
class to be called.

13)What are the different types of access modifiers / specifier in Java?


special types of keywords that are used to specify or control the accessibility of
entities like classes, methods, and so on.
-Public, Protected, Default, Private
-Public: Accessible from anywhere.
-Protected: Accessible within the same package or by subclasses.
-Default (no modifier): Accessible only within the same package.
-Private: Accessible only within the same class.

14)What is the difference between StringBuffer and StringBuilder?


-StrngBuffer is synchronized, which makes it is thread-safe, but it is slower than
StringBulder.
-StrngBuilder is not synchronized, making it faster, but it is not thread-safe.

15)What are the differences between HashSet, TreeSet, and LinkedHashSet?


-HshSet: Set interface using a hsh table. It does not maintain the insertion order
of elements. HshSet allows one null element.
-tree Set: Implements the Sorted Set interface using a red-black tree. It maintains
the elements in sorted order either in natural order or according to a specified
comparator.it does not allow null elements
-LinkedHshSet: Extends HshSet and maintains the insertion order of elements using a
doubly linked list. It allows one null element and none of them are synchronised

16)Explain the concept of serialization and deserialization in Java


- process of converting an object into a byte stream so that it can be stored in a
file or sent over the network is called serialization.
-and Desrialization is the process of converting the byte stream back into an
object.

17)What are lambda expressions in Java?


- Lambda expressions introduce a concise way to represent anonymous functions in
Java. They facilitate functional programming by treating functionality as a method
argument. Lambda expressions can be used to represent instances of functional
interfaces.

18)what is a java stream


-sequence of elements that supports various aggregate operations, they are
performed sequentially or in parallel
-support functional-style operations meaning you could perform operations on
elements of stream without mutating the original data structure
-processed sequentially or in parallel, allowing for concurrent execution of
operations on the elements of the stream
-operations are categorized as either intermediate or terminal where ntermediate
operations return a new stream and are typically chained together, while terminal
operations produce a result or side effect and terminate the stream.

19)Object-Oriented Programming (OOP)


-programming paradigm where complete sw operates as a bunch of objects talking to
each other, It emphasizes modularity, reusability, and extensibility.
-4 principles op oop are Encapsulation, Inheritance, Polymorphism, and Abstraction
20)Encapsulation?
-it basically the bundling of data and methods that operate on the data into a
single unit, known as a class. It hides the internal state of an object and only
exposes the necessary methods to interact with it.

21)Inheritance?
-mechanism by which a class can inherit attributes and methods from another
class.it increase code reusability and it also achives runtime polymorphism

22)Polymorphism?
-ability of objects to take on multiple forms.
-classified into two types based on the time when the call to the object or
function is resolved.
-Compile-time Polymorphism (Static Polymorphism):
Compile-time polymorphism refers to the polymorphic behavior that is resolved at
compile time.
It is achieved through method overloding, where multiple methods with the same name
but different parameter lists are defined within the same class.
The appropriate method to execute is determined by the compiler based on the number
and types of arguments passed to the method.
-Runtime Polymorphism (Dynamic Polymorphism):
Runtime polymorphism refers to the polymorphic behavior that is resolved at
runtime.
It is achieved through method overriding, where a subclass provides a specific
implementation of a method that is already defined in its superclass.
The appropriate method to execute is determined by the JVM based on the type of the
object at runtime.

23)Abstraction?
-simplifies complex systems by modeling classes based on their essential
characteristics and ignoring irrelevant details. It enables the creation of
abstract data types and interfaces, allowing for code reuse and modular design.

24) difference between Composition and Inheritance?


-Composition involves creating complex objects by combining simpler objects. It
allows for better encapsulation and flexibility.
-Inheritance involves creating new classes based on existing ones, inheriting their
attributes and methods.it can lead to tight coupling and less flexibility.

25)What is the difference between a Class and an Object?


-class is a blueprint for creating objects. It defines the attributes and behaviors
that objects of that class will have.
-object is an instance of a class. It represents a specific instance of the class,
with its own set of attribute values.

A Comparator in Java is an interface which provides a way to define custom


comparison logic for sorting objects.

BigInteger is particularly useful when dealing with very large numbers that cannot
be represented by the built-in integer types. It supports operations such as
addition, subtraction, multiplication, division, and exponentiation on large
integers, without loss of precision.

You might also like