Data Abstraction may also be defined as the process of identifying only the required characteristics of an object ignoring the irrelevant details.The properties and behaviors of an object differentiate it from other objects of similar type and also help in classifying/grouping the objects. Consider a real-life example of a man driving a car. The man Continue reading
Category: Java Basics
Interface explained with example
Credits: Naveen reddy (Telusko youtube channel)www.geeksforgeeks.org Like a class, an interface can have methods and variables, but the methods declared in interface are by default abstract (only method signature, no body). Interfaces specify what a class must do and not how. It is the blueprint of the class. If a class implements an interface and Continue reading
variable-length arguments in Java
Prior to JDK 5, variable-length arguments could be handled two ways. One using overloaded method(one for each) and another put the arguments into an array, and then pass this array to the method. Both of them are potentially error-prone and require more code. The varargs feature offers a simpler, better option. Syntax of varargs :A Continue reading
JDK, JRE, JVM
JDK Contains various APIs and libs like Java.io, javac, java etc It gives the required packages for java developer to work on JVM and jre JRE It is runtime environment, which implements JVM and provides all class libraries and other files that JVM requires at runtime JVM It is where the bytecode is executed
Synchronisation in Java
It is a process which keeps all concurrent threads in execution to be in sync while trying to access the same object at the same time. It prevents memory consistency errors caused due to inconsistent view of shared memory. Ex BookMyShow, multiple users try to book tickets at same time but ticket selected by one Continue reading
Process vs thread
A process is a running instance of program over OS – A thread is running on top of process – OS, there is multi processing on OS level – Multiple thread, multi threading in process level – Process run on separate memory space – Thread runs on shared memory space
Wrapper class in Java
– Each of java’s 8 primitive data types has a class dedicated to it. These are known as wrapper class– They wrap the primitive data type into an object of that class– Ex- boolean has Boolean, byte has Byte etc– int is single value container , primitive data type– Integer iRef = new Integer(i)- it Continue reading
final, finally, finalize
Final is used to apply restrictions on class, method,variable Final class can not be inherited, final method can not be over ridden, final variable can not be changed Finally is used mostly with try catch in exception handling it is used to execute the code which needs to be executed irrespective of the exception Ex Continue reading