0% found this document useful (0 votes)
11 views2 pages

Day 2

The document provides an overview of key Java concepts including the 'this' keyword, access modifiers, encapsulation, abstract classes, interfaces, exception handling, and multithreading. It explains the differences between arrays and collections, highlighting their characteristics and usage. Additionally, it covers exception types and handling mechanisms to prevent program termination.

Uploaded by

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

Day 2

The document provides an overview of key Java concepts including the 'this' keyword, access modifiers, encapsulation, abstract classes, interfaces, exception handling, and multithreading. It explains the differences between arrays and collections, highlighting their characteristics and usage. Additionally, it covers exception types and handling mechanisms to prevent program termination.

Uploaded by

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

day2:may1

This keyword:
The this keyword refers to the current object in a method or constructor. The most
common use of the this keyword is to eliminate the confusion
between class attributes and parameters with the same name .

modifiers: private,protected,default,public.
non access modifiers: static, final ,abstarct,synchronized,transient.
**only final keywork is for only local modifiers.
private: a class cant be private,
private keyword can be used for data members,inner classes,methods.
private members accessed with in the class.

protected: it is same as class but members are accessed with in same package/
another package.
public: a class can be public , where name of the class same as source code file
name,accessible any where.

Encapsulation: binding/wrapping of the combined data( data members+ methods) in a


container called as one class and provide security to data members.

abstract classes:
it is used to set rules
an abstract keyword is used for method as wellas abstract class
**if any class extends abstract class then we have to override all abstract methods
else make the class as abstarct
**we cant create objects for abstarct classes.

Interfaces:it is used to forms the rules and specifications


doesn't force is-a relationship
all datamembers are by default they are publlic,static,final\
in Interface all methods are public and abstract.
** if a class implements interface we need to override the all abstarct methods
else make class as abstract.
a class can extends multiple interfaces
a interface extends multiple interfaces.

EXCEPTION HANDLING:
types of errors:
compile time/syntax errors
logical errors/semantic
runtime erros/exception

an exception is a runtime error which occurs during program execution and


terminates the program suddenly.

checked,unchecked,error are different types of exceptions. ex:sql injection


checked is like eoor at compile time,unchecked exceptions mainly occur at
runtime .
where errors are arthimetic etc..ex: null pointer, array out of bounds.

excdeption handling is to avoid termination of a program it makes the


program works fine with the help of some exception keywords:
blocks:try,catch,finally
clauses:throw,throws
finally block is used to do closing operations.
user defined exceptions/custom exceptions: creating a class which is
subclass of exception class.
throw: define our own set of conditions and throw an exception explicitly
using throw keyword. For example, we can throw ArithmeticException
if we divide a number by another number. Here, we just need to set the
condition and throw exception using throw keyword.

multithreading is used to increase the performance of application?--


Multithreading is a Java feature that allows concurrent execution of two or
more parts of a program for maximum utilization of CPU.
Each part of such program is called a thread.
Multithreading in Java is a process of executing multiple threads
simultaneously.
sleep() when this invoked on thread ,the thread go to block state of some
milli seconds for ex: etc
thread.sleep(1000)

arrays vs collections--->
arrays--- fixed size ,continuous memory similar datatype
collections---opposite to arrays.
map: collect elements in key value pairs
set:is unordered
list:elements are ordered.

linkedlists:less memory <<array, no continuous memory, operations are less cost

You might also like