© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Operators ▼

Java Interview Questions On Operators

22. Which of the following answers return true when you replace in the place of XXXXXXXXX?
public class TestType {
public static void main(String args[] ) {
Button b = new Button("BUTTON");
if( XXXXXXXXX) {
System.out.print("This is an instance of Buton");
}
}
}
[a] b instanceof Button
[b] Button instanceof b
[c] b == Button
[d] Button == (Object) b

Answer
[a] b instanceof Button

23. Which of the following compiles without an error?
interface A {}
class TestBase implements A{}
public class TestChild extends TestBase {
public static void main(String args[]) {
TestBase tb = new TestBase();
TestChild tc = new TestChild();
}
}
[a] tb = tc
[b] tc = tb
[c] TestChild tc = new TestBase()
[d] A a = new TestChild()

Answer
[a] tb = tc
[d] A a = new TestChild()

24. What will be the result of following program?
public class MyClass {
public static void main(String args[]) {
String str1 = "Test One";
String str2 = new String("Test One");
if ( str1.equals( str2) ) {
System.out.println("Both are equal");
}
boolean b = true;
boolean b1 = false;
if ( b.equals(b1) ) {
System.out.println("true");
}

}
}
[a] Compile time error
[b] Runtime error.
[c] No output
[d] "Both are equal" followed by "true"

Answer
[a] Compile time error

Previous Next
1 2 3 4 5 6 7
SLogix Student Projects
bottom