The map is an interface
javap java._____.String
Sorted map extends
All methods must be implemented in an interface?
What are the correct statements about Java packages?
What is the correct way to implement an interface?
For example, ‘Operation’ interface implements ‘Add’ class.
Predict the output of the following Java code:
//Predict the output
import java.util.Scanner;
public class MyClass
{
public static void main(String args[])
{
String str = "How to work java in java compiler";
String Str1 = str.replaceAll("java", "c");
System.out.println(Str1);
}
}
class method
{
private int i;
static int j;
void add(int a , int b)
{
i =++j + ++b;
j =++i + b++;
}
}
class output
{
public static void main(String args[])
{
method obj1 = new method();
method obj2 = new method();
int a = 5;
obj1.add(++a, ++a + 1);
obj2.add(6, a);
System.out.println(obj1.i+" "+obj2.j);
}
}
What will be the output of the following Java code?
class Abekus {
public static void main(String args[]) {
String str1 = new String("Hi Java Learner");
String str2 = new String("Hi Java Learner");
String str3 = "Hi Java Learner";
String str4 = "Hi Java Learner";
int a = 0, b = 0, c = 0;
if (str3 == str4) a = 1;
else a = 2;
if (str1.equals(str3)) b = 1;
else b = 2;
if (str1 == str4) c = 1;
else c = 2;
System.out.println("a= " + a + " b= " + b + " c= " + c);
}
}
Predict the output of the following Java code:
class Hashcode {
public static void main(String[] args) {
String o1 = new String("Abekus");
String o2 = new String("Abekus");
if(o1.hashCode() == o2.hashCode())
System.out.println("Hashcode of object1 is equal to object2.");
if(o1 == o2)
System.out.println("Memory address of object1 is same as object2.");
if(o1.equals(o2))
System.out.println("Value of object1 is equal to object2.");
}
}