Write a Program that generates the following output:
10
20
19
Note: Do not use any if else statements. Only one variable is allowed, no other variable or number is allowed. Only use simple Arithmetic Operation.
Answers
Answer:
Predict the output of following Java Programs.
Program 1:
filter_none
edit
play_arrow
brightness_4
class GfG
{
public static void main(String args[])
{
String s1 = new String("geeksforgeeks");
String s2 = new String("geeksforgeeks");
if (s1 == s2)
System.out.println("Equal");
else
System.out.println("Not equal");
}
}
Output:
Not equal
Explanation: Since, s1 and s2 are two different objects the references are not the same, and the == operator compares object reference. So it prints “Not equal”, to compare the actual characters in the string .equals() method must be used.
Explanation:
if you are pleased with answer in turn
please subscribe my youtube chanel(Ramakrishna Nallangari youtube channel) for my effort
search for
Ramakrishna Nallangari in search box
of youtube