Interview Questions and Answers - Order By Rating Q121. In the following code , how many methods needs to be implemented in Class B ?
public interface A{
public void method1();
public void method2();
public void method3();
}
abstract class B implements A{
} Core Java
Ans. As Class B has been declared abstract , we can either implement any of these methods and just declare rest of them abstract. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  interfaces  abstract classes  code  coding Try 2 Question(s) TestRelated Questions Differences between abstract class and interface ? Difference between Abstract and Concrete Class ? If an Abstract class has only abstract methods, What's the difference between such a class and an interface ? What are the design considerations while making a choice between using interface and abstract class ? How is Abstraction implemented in Java ? Why can't we create an instance of abstract class ? Why is it restricted by compiler ? Difference between Base Class, Derived Class , Abstract Class and Concrete Class ? What is an abstract class ? Shall we use abstract classes or Interfaces in Policy / Strategy Design Pattern ? Will this code Work ? If not , Why ? Q122. What will the following code print ?
Integer a = 100, b =100;
Integer c = 1000, d = 1000;
System.out.println(a == b);
System.out.println(c ==d); Core Java
Ans. false
false Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  object equality  code  coding   frequent Related Questions Difference between == and .equals() ? Why is null == null returns true ? What is the difference between = and == in Java ? How is == operator different for objects and primitive types ? What will be the output of following code
Integer x = 1;
Integer y = 2;
System.out.println(x == y);
What if you change 1 to "1" and Integer to String? How can we check equality for Arrays in Java ? Q123. What will be the output of following code ?
public class BuggyBread {
private int x;
private BuggyBread(int x){
x = x;
};
public static void main(String[] args){
BuggyBread buggybread = new BuggyBread(5);
System.out.println(buggybread.x);
}
}
Core Java
a. compilation error b. undefined c. 0 d. 5Ans.c. 0