Answer:
Code is completed below
Explanation:
Source Code in Java:
class Parenthesis
{
boolean hasBalancedParentheses(String eq) //method to check and return if a set of parenthesis is balanced or not
{
int count=0; //to store count of current unclosed opening brackets
for(int i=0;i<eq.length();i++)
{
if(eq.charAt(i)=='(')
count++;
else if(eq.charAt(i)==')')
count--;
if(count<0) //if count falls below zero, there were more closing brackets than opening brackets till this point
return false;
}
if(count>0) //if count is still more than zero, there were less closing brackets than opening brackets
return false;
return true; //if program reaches this point, it has passed all the tests
}
public static void main(String args[])
{
//testing the function
Parenthesis ob=new Parenthesis();
System.out.println(ob.hasBalancedParentheses("()(()())((())())"));
System.out.println(ob.hasBalancedParentheses(")((()())(()))())"));
}
}
Answer:
retupmoc
Explanation:
1.) Anwser will be retupmoc
because
public static String mysteryString(String s){
if(s.length() == 1){
return s;
}
else{
return s.substring(s.length() -1) + mysteryString(s.substring(0, s.length()-1));
}
}
In this program input is "computer" . So the function mysteryString(String s) it does
return s.substring(s.length() -1) + mysteryString(s.substring(0, s.length()-1));
so when it enters the first time ??s.substring(s.length() -1) and it will be give you 'r' then it calls the function recursively by reducing the string length by one . So next time it calls the mysteryString function with string "compute" and next time it calls return s.substring(s.length()-1)? + mysteryString(s.substring(0,s.length-1)) so this time it gives "e" and calls the function again recursively . It keeps on doing till it matched the base case.
so it returns "retupmoc".
Each language has its own use, some of them are used to create or manipulate back end codes and some of them are used mainly for web designing and some of them are used for data entries and control of data that is being implanted in the system, so if you put all uses in one language it will not be a simple task as it is nowadays for programmers. That is why there are different compt. langs.
Answer:
False is the correct answer for the above question.
Explanation:
- The structure is a user-defined data type, which is used to define the set of different data types and values. Just like in the above question, the class structure holds the list of three variables, which is a type of double.
- When any user wants to compare the two structure values, then he can do it with the help of comparing all the variables of a structure. if a user wants to compare the circle1 with the value of the circle2, then he needs to compare the circle1.centerX with circle2.centerX, and so on with the other variables.
- But the above question syntax will directly compare the two structure variable, which is not correct. Hence the above answer is false.