//////////////////////////////polymorphism//////////////////////////////
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class Solution {
public static void main(String args[] ) throws Exception {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
Scanner sc = new Scanner([Link]);
int m = [Link]();
int n= [Link]();
int p=m;
int q=n;
for(int i = m ; i <= n ; i++)
{
//logic for checking number is prime or not
int count = 0;
for(int j = 1 ; j <= i ; j++)
{
if(i % j == 0)
count = count+1;
}
if(count == 2)
[Link](i+" ");
}
int sum=0,r,i,n1;
[Link]("");
for(i=m;i<=n;i++)
{
n1=i;
sum=0;
//checking for happy number
while(sum!=1 && sum!=4)
{
sum=0;
while(n1>0)
{
r=n1%10;
sum+=(r*r);
n1=n1/10;
}
n1=sum;
}
//printing the result
if(sum==1)
[Link](i+" ");
}
}
}
//////////////////////Multiple Inheritence////////////////////////
import [Link];
import [Link];
import [Link].*;
interface HockeyTeam{
public int calculateHockeyScore();
public int findHighestGoalByIndividualInHockey();
}
interface FootballTeam{
public int calculateFootballScore();
public int findHighestGoalByIndividualInFootball();
}
class Sport implements HockeyTeam,FootballTeam{
int []hockeyPlayers = new int[11];
int []FootballPlayers = new int[11];
//Scanner sc = new Scanner([Link]);
Sport(int[] paramHockeyPlayers,int[] paramFootballPlayers){
for(int i=0;i<[Link];i++){
hockeyPlayers[i]=paramHockeyPlayers[i];
}
for(int k=0;k<[Link];k++){
FootballPlayers[k]=paramFootballPlayers[k];
}
}
public int calculateHockeyScore(){
int sum = 0;
//[Link]("Enter the elements of the array one by one ");
for(int i=0; i<[Link]; i++){
//hockeyPlayers[i] = [Link]();
sum = sum + hockeyPlayers[i];
}
return sum;
}
public int calculateFootballScore(){
int sum = 0;
//[Link]("Enter the elements of the array one by one ");
for(int i=0; i<[Link]; i++){
//FootballPlayers[i] = [Link]();
sum = sum + FootballPlayers[i];
}
return sum;
}
public int findHighestGoalByIndividualInHockey(){
int max = hockeyPlayers[0];
//Loop through the array
for (int i = 0; i < [Link]; i++) {
//Compare elements of array with max
if(hockeyPlayers[i] > max)
max = hockeyPlayers[i];
}
return max;
}
public int findHighestGoalByIndividualInFootball(){
int max = FootballPlayers[0];
//Loop through the array
for (int i = 0; i < [Link]; i++) {
//Compare elements of array with max
if(FootballPlayers[i] > max)
max = FootballPlayers[i];
}
return max;
}
}
ublic class Solution{
public static void main(String args[])
{
Scanner sc = new Scanner([Link]);
int[] hockeyPlayers = new int[11];
int[] footballPlayers = new int[11];
for(int i = 0; i < 11; i++)
{
hockeyPlayers[i] = [Link]();
}
for(int i = 0; i < 11; i++)
{
footballPlayers[i] = [Link]();
}
Sport s = new Sport(hockeyPlayers, footballPlayers);
try{
[Link]("calculateHockeyScore");
[Link]("findHighestGoalByIndividualInHockey");
[Link]("calculateFootballScore");
[Link]("findHighestGoalByIndividualInFootball");
if(s instanceof HockeyTeam && s instanceof FootballTeam)
{
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
}
}
catch (NoSuchMethodException ex)
{
[Link]("No such function is exits");
}
}
}
/////////////////////multi threading///////////////////////
import [Link];
class Task1 extends Thread {
static int a = 0;
static int beg = 0;
public void run(){
for(int i=beg;i < a;i++)
[Link][i] = i;
}
}
class Task2 extends Thread {
static int a = 0;
static int beg = 0;
public void run(){
for(int i=beg; i< beg + a;i++)
[Link][i] = i;
}
}
class Task3 extends Thread{
static int a = 0;
static int beg = 0;
public void run(){
for(int i=beg;i< a + beg;i++)
[Link][i] = i;
}
}
public class Solution
{
public static final int[] threadArray = new int[300];
public static volatile String i = 0+"";
public boolean test() throws InterruptedException
{
Task1 task1 = new Task1();
Task2 task2 = new Task2();
Task3 task3 = new Task3();
Thread task2Thread = new Thread(task2);
Thread task3Thread = new Thread(task3);
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
int first = Task1.a+Task2.a;
int containsSecondThread = Task1.a;
String oneAndTwo = "";
String sizeOfTask1 = "";
for(int i=0;i<first;i++)
{
oneAndTwo += threadArray[i]+" ";
}
for(int i=0;i<containsSecondThread;i++)
{
sizeOfTask1 += threadArray[i]+" ";
}
int begOfTask3 = [Link];
String checkingString = "";
for(int i=begOfTask3;i<[Link];i++)
{
checkingString += i + " ";
}
String task3String = "";
for(int j = begOfTask3;j<[Link];j++)
{
task3String += threadArray[j]+" ";
}
if(( &&
[Link]([Link]+"")) || [Link](checkingString))
{
return true;
}
return false;
}
public static void main(String[] args) throws InterruptedException
{
Scanner sc= new Scanner([Link]);
Solution solution = new Solution();
int one = [Link]();
Task1.a = one;
[Link] = 0;
int two = [Link]();
Task2.a = two;
[Link] = one;
int three = [Link]();
Task3.a = three;
[Link] = one+two;
[Link]([Link]());
}
}