Answer:
Program.java
import java.util.Scanner;
public class Program {
public static boolean isPalindrome(String str){
int start = 0, end = str.length()-1;
while (start < end){
if(str.charAt(start) != str.charAt(end)){
return false;
}
start++;
end--;
}
return true;
}
public static int countPalindromePairs(String[] inarr){
int count = 0;
for(int i=0; i<inarr.length; i++){
for(int j=i+1; j<inarr.length; j++){
StringBuilder sb = new StringBuilder();
sb.append(inarr[i]).append(inarr[j]);
if(isPalindrome(sb.toString())){
count++;
}
}
}
return count == 0 ? -1 : count;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String line = sc.next();
String[] inarr = line.split(",");
int count = countPalindromePairs(inarr);
System.out.println("RESULT: "+count);
}
}
Explanation:
OUTPUT:
Answer:
An alert appears on the other devices
Explanation:
On social media platforms, whenever some one make a post, all the person who are using that social media app and present in the friend circle of that particular person receive an alert containing the information of the post.
The alert that received by different users on a social media platform is known as Notification. This notification is a type of text, in which the activity performed by post creator is mentioned, this text is received with the tone called notification tone.
The purpose of the alert is to informs the friends who are using that social media platform that a post has been published by someone.
Answer:
E. New technology is beneficial but can also be used in a detrimental way.
Explanation:
New technology such as cryptocurrency (powered by blockchain technology) can be regarded as a welcome development that has benefited the society in so many good ways. However, cryptocurrency as a new technology also has disadvantages it presents to the society. One of such negative influence cryptocurrency has is that it can be used for illicit activities such as money laundering, funding terrorism and so on.
So, in summary, we can conclude that:
"New technology is beneficial but can also be used in a detrimental way."
Answer:
Following are the code to the given question:
#include <iostream>//header file
using namespace std;
class Window //defining a class Window
{
private:
int width, height;//defining integer variable
public:
friend ostream& operator << (ostream& stm, Window& width)//defining a friend function that takes two parameters
{
return stm<<"a ("<<width.width<<" x "<<width.height<<") window"; //use return keyword that return its values
}
Window(int width, int height): width(width), height(height)//defining parameterized constructor that inherit width and height in its parameters
{}
};
int main() //Main method
{
Window w(80,90);//calling class constructor
cout<<w;//print object value
return 0;
}
Output:
a (80 x 90) window
Explanation:
In the above code, a class "Window" is defined that uses a friend function "ostream& operator" is declared that uses the "ostrea&" as a data type to hold two-variable "stm and w" in its parameter, and declared the parameterized constructor to hold value by inheriting width and height in its parameters.
Inside the main method, a class object is created that calls the constructor and uses the print method to print object value.
Answer:
It would be correct to say that out-of-order makes a machine's performance more sensitive to branch prediction accuracy.
Explanation:
This can be explained as when a machine is out-of-order, in that state the execution holds importance in prediction accuracy, any increase in these results in rate of prediction near about 25% for the single-issue operating in-order. This is due to the reason that some of the predictions are required for the global pattern history. Most recent outcomes are recorded in the register and for a 4-way machine which is out-of-order, accuracy is very poor as a result of the delay of the branch history for next prediction.