
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

2K+ Views
The BufferedWriter class of Java is used to write stream of characters to the specified destination (character-output stream). It initially stores all the characters in a buffer and pushes the contents of the buffer to the destination, making the writing of characters, arrays and Strings efficient.You can specify the required size of the buffer at the time of instantiating this class.The flush() methodWhile you are trying to write data to a Stream using the BufferedWriter object, after invoking the write() method the data will be buffered initially, nothing will be printed.The flush() method is used to push the contents of ... Read More

218 Views
To compare two objects, the Object class provides a method with name equals(), this method accepts an object and compares it with the current object.If the references of these two objects are equal, then it returns true else this method returns false.But this method returns true only if both references points to the same object. In fact, it should return true id the contents of the both objects are equal.Exampleclass Employee { private String name; private int age; Employee(String name, int age){ this.name = name; this.age = age; } } ... Read More

304 Views
This article will discuss how to convert a hexadecimal value to a byte value in Java. Before converting it to a byte, let's first understand what hexadecimal and byte values are. Hexadecimal Value In Java, a hexadecimal number is a base-16 number represented using the digits 0-9 and the letters A-F or a-f, where A-F represent the decimal values 10-15 respectively. The hexadecimal values are: 0x1A 0xFF 0x0A Byte Value In Java, a byte is a data type that can store whole numbers between the ... Read More

22K+ Views
The String type is a class in Java, it is used to represent a set of characters. Strings in Java are immutable, you cannot change the value of a String once created.Since a String is immutable, if you try to reassign the value of a String. The reference of it will be pointed to the new String object leaving an unused String in the memory.Java provides StringBuffer class as a replacement of Strings in places where there is a necessity to make a lot of modifications to Strings of characters.You can modify/manipulate the contents of a StringBuffer over and over again ... Read More

3K+ Views
A map is a collection in Java which stores key value pairs. The keys of this must not be null and each key should point to only one value. It is represented by the Map interface of java.util package. There are various classes which provides implementation to this interface.The HashMap is a class which implements the Map interface. It is based on the Hash table. It allows null values and null keys.In short, you can store key value pairs in the HashMap object. Once you do so you can retrieve the values of the respective keys but, the values we ... Read More

2K+ Views
A thread is a piece of code (under execution) in a program, which executes a sub task of the process independently. independent process.In other words, a thread is a light weight process which executes a piece of code independently.Thread synchronizationIf a process has multiple threads running independently at the same time (multi-threading) and if all of them trying to access a same resource an issue occurs.To resolve this, Java provides synchronized blocks/ synchronized methods. If you define a resource (variable/object/array) inside a synchronized block or a synchronized method, if one thread is using/accessing it, other threads are not allowed to ... Read More

363 Views
Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double.Java strictly specifies range and behaviors of all the primitive datatypes. Making the users choose the required datatypes based on the application thus reducing the unused occupancy of memory.For example, if you need to store an integer constant of single digit using integer would be a waste of memory instead, you can use byte type since 8 bits would be necessary to store it.ExampleFollowing Java example lists out the ranges of the primitive datatypes.public class ... Read More

7K+ Views
The println() method of the System class accepts aStringas parameter an prints the given String on the console.Examplepublic class PrintData { public static void main(String args[]) { System.out.println("Hello how are you"); } }OutputHello how are youIn addition to this you can print data on the console in several other ways, some of them are −Using Output StreamsUsing output stream classes, you can write dat on the specified destination. You can print data on the screen/console by passing the standard output Stream object System.out as source to them.Exampleimport java.io.IOException; import java.io.OutputStreamWriter; public class PrintData { ... Read More

510 Views
When you create instance variables in Java you need to initialize them, else the compiler will initialize on your behalf with default values which are −byte: 0short: 0int: 0long: 0float: 0.0double: 0.0boolean: falsestring: nullExampleIn the following Java program prints the default values of the numeric and non-numeric primitive variables in java.public class DefaultValues { byte byteVariable; short shortVariable; int intVariable; long longVaraible; float floatVariable; double doubleVariable; boolean boolVariable; String stringVariable; public static void main(String args[]){ DefaultValues obj = new DefaultValues(); System.out.println("Default values of numeric variables ... Read More

1K+ Views
When a class has two or more methods by the same name but different parameters, at the time of calling, based on the parameters passed, respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.Exampleclass Test{ public int addition(int a, int b){ int result = a+b; return result; } public int addition (int a, int b, int c){ int result = a+b+c; return result; } public static void main(String args[]){ ... Read More