Go Back

Java7 - Sample Interview Question (Junior Level)

What do you think of the following Java code?

//CustomTest.java

package pack2;

public abstract class CustomTest {
abstract String getCustomTestName();
}

//Test.java

package pack1;

import pack2.CustomTest;

public class Test extends CustomTest{
private String testName;
public String getCustomTestName(){
return testName;
}
}


  1. The code will compile and run well
  2. The code fails to compile, to correct it you have to change the method getCustomTestName in class CustomTest to protected
  3. The code fails to compile, to correct it you have to change the method getCustomTestName in class Test to public
  4. None of the above
Tests in Java7 for Juniors

Test Name Difficulty Time (minutes) No. of Questions
Java7 Junior 20 10