
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

1K+ Views
Keywords in Java are reserved words that represent predefined actions, internal processes etc. Because of this, keywords cannot be used as names of variables, functions, objects etc.The main difference between keywords and identifiers is that keywords are reserved words that represent predefined actions while identifiers are the names of variables, functions, objects etc.Some of the keywords in the Java are given as follows −abstractassertbooleanbreakbytecasecatchcharclassconstcontinuedefaultdodoubleelseenumextendsfinalfinallyfloatforgotoifimplementsimportinstanceofintinterfacelongnativenewpackageprivateprotectedpublicreturnshortstaticstrictfpsuperswitchsynchronizedthisthrowthrowstransienttryvoidvolatilewhileA program that demonstrates keywords is given as follows −Example Live Demopublic class Example { public static void main(String[] args) { int i = 5; char c = 'A'; System.out.println("i = " + i); System.out.println("c = " + ... Read More

923 Views
The dequeue is a double ended queue and data elements can be added or removed from either end. The dequeue in Java is implemented using the java.util.Deque interface which is a subtype of the java.util.Queue interface.A program that demonstrates some of the methods of a dequeue is given as follows −Example Live Demoimport java.util.*; public class Example { public static void main(String[] args) { Deque d = new LinkedList(); d.add("5"); d.addFirst("1"); d.addLast("9"); d.push("7"); d.offer("8"); d.offerFirst("6"); d.offerLast("2"); ... Read More

818 Views
Java provides the Date class available in java.util package, this class encapsulates the current date and time. The time functions can be accessed from the java.util.Date class. This represents an instance of time with millisecond precision.One of the time function in Java is the getTime() function. It returns the number of milliseconds that have passed since January 1, 1970, 00:00:00 GMT. A program that demonstrates this is given as follows −Example Live Demoimport java.util.*; public class Example { public static void main(String[] args) { Date d = new Date(95, 7, 15); long num = ... Read More

7K+ Views
Matrix multiplication leads to a new matrix by multiplying 2 matrices. But this is only possible if the columns of the first matrix are equal to the rows of the second matrix. An example of matrix multiplication with square matrices is given as follows.Example Live Demopublic class Example { public static void main(String args[]) { int n = 3; int[][] a = { {5, 2, 3}, {2, 6, 3}, {6, 9, 1} }; int[][] b = { {2, 7, 5}, {1, 4, 3}, {1, 2, 1} }; int[][] ... Read More

2K+ Views
The words are sorted in lexicographical order or dictionary order. This means that the words are alphabetically ordered based on their component alphabets. An example of this is given as follows.The original order of the words is Tom Anne Sally John The lexicographical order of the words is Anne John Sally TomA program that demonstrates this is given as follows.Example Live Demopublic class Example { public static void main(String[] args) { String[] words = { "Peach", "Orange", "Mango", "Cherry", "Apple" }; int n = 5; System.out.println("The original order of the words ... Read More

9K+ Views
Two sorted arrays can be merged so that a single resultant sorted array is obtained. An example of this is given as follows.Array 1 = 1 3 7 9 10 Array 2 = 2 5 8 Merged array = 1 2 3 5 7 8 9 10A program that demonstrates this is given as follows.Example Live Demopublic class Example { public static void main (String[] args) { int[] arr1 = {11, 34, 66, 75}; int n1 = arr1.length; int[] arr2 = {1, 5, 19, 50, 89, 100}; int ... Read More

5K+ Views
The order of the words in a string can be reversed and the string displayed with the words in reverse order. An example of this is given as follows.String = I love mangoes Reversed string = mangoes love IA program that demonstrates this is given as follows.Example Live Demoimport java.util.regex.Pattern; public class Example { public static void main(String[] args) { String str = "the sky is blue"; Pattern p = Pattern.compile("\s"); System.out.println("The original string is: " + str); String[] temp = p.split(str); String rev = ... Read More

30K+ Views
The Body Mass Index is the body mass in kilogram divided by the square of body height in meters. This is expressed as kg/m^2.A Java program that calculates the Body Mass Index (BMI) is given as follows.Exampleimport java.util.Scanner; public class Example { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Input weight in kilogram: "); double weight = sc.nextDouble(); System.out.print("Input height in meters: "); double height = sc.nextDouble(); double BMI = weight / (height * height); ... Read More

1K+ Views
Suppose you are given two strings, your task is to write a Java program that checks whether the second string is the sub-string of the first one. String in Java is an immutable sequence of characters and sub-string is its small portion. Example Scenario: − Input 1: str = "The sunset is beautiful"; Input 2: sub_str = "sunset"; Output: res = found!! Using Iteration In this approach, the idea is to use a nested for loop and an if block. The outer for loop will iterate over the characters of the main string. For each starting position i, ... Read More

338 Views
To check whether the entered value is ASCII 7-bit printable, check whether the characters ASCII value is greater than equal to 32 and less than 127 or not. These are the control characters.Here, we have a character.char one = '^';Now, we have checked a condition with if-else for printable characters.if (c >= 32 && c < 127) { System.out.println("Given value is printable!"); } else { System.out.println("Given value is not printable!"); }Example Live Demopublic class Demo { public static void main(String []args) { char c = '^'; System.out.println("Given value = "+c); ... Read More