Topic- looping,function overloading,nesting ,polymorphism.
Aim - to write a function with a name buzz-buds,that will
check whether the given numbers are buddies or not on the
basis of no. of parameters passed during function calling.



Topic- looping,function overloading,nesting ,polymorphism. Aim - to write a function with a name bu..

Answer / Money Taygi

Here's an example in Java:nn```npublic class BuzzBuds {n public static void buzzBuds(int num1, int num2) {n System.out.printf("%d and %d are buddies.", num1, num2);n }nn public static void buzzBuds(int num) {n for (int i = 1; i <= num; i++) {n if (isPrime(i)) {n buzzBuds(i * i, i * i + 1);n }n }n }nn public static boolean isPrime(int num) {n if (num <= 1) return false;n for (int i = 2; i <= Math.sqrt(num); i++) {n if (num % i == 0) return false;n }n return true;n }n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Java Related AllOther Interview Questions

What is the difference between lambda expression and anonymous methods?

1 Answers  


What's the difference between authentication and authorization? : java security

1 Answers  


What is difference between loosely coupled and tightly coupled in java?

1 Answers  


What is jdk jre and jvm?

1 Answers  


What is stateless in java?

1 Answers  


What is entitymanager in java?

1 Answers  


What is the difference between jar and executable jar?

1 Answers  


What is stateful in java?

1 Answers  


What is java lang exceptionininitializererror?

1 Answers  


What is savepoint in java?

1 Answers  


What are the advantages of java 8’s date and time api over old date api and joda time api?

1 Answers  


Is java an api?

1 Answers  


Categories