This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
class Ideone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object. | |
//It is an important part of OOPs (Object Oriented programming system). | |
class Employee{ | |
float salary=40000; | |
} | |
class Programmer extends Employee{ | |
int bonus=10000; | |
public static void main(String args[]){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1-If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java. | |
2-In other words, If a subclass provides the specific implementation of the method that has been declared by one of its parent class, | |
it is known as method overriding. | |
//Java Program to illustrate the use of Java Method Overriding | |
//Creating a parent class. | |
class Vehicle{ | |
//defining a method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//If a class has multiple methods having same name but different in parameters, it is known as Method Overloading. | |
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
class Ideone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input: | |
6 | |
5 | |
1 3 5 7 9 11 | |
output: | |
Success #stdin #stdout 0.1s 49484KB | |
element found | |
/* package whatever; // don't place package name! */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
Before Rotation | |
1 2 3 | |
4 5 6 | |
7 8 9 | |
after rotation | |
7 4 1 | |
8 5 2 | |
9 6 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
class Ideone | |
{ | |
public static void main (String[] args) throws java.lang.Exception |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example:- | |
input: | |
array size=5 | |
kth number =2 | |
arr[]={9,2,15,3,16} | |
/* package whatever; // don't place package name! */ | |
import java.util.*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example:- | |
input: | |
array size=5 | |
kth =3 | |
arr[]={9 12 2 15 2} | |
output: | |
9 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example-1 | |
input;- | |
I am a very good engineer | |
very | |
output:- | |
I am a good engineer | |
NewerOlder