Which four can be thrown using the throw statement?
- Erro
Practice Exceptions –
Which four can be thrown using the throw statement?
- Error
- Event
- Object
- Throwable
- Exception
- RuntimeException
Which four can be thrown using the throw statement?
Practice Exceptions –
Which four can be thrown using the throw statement?
Which of the following would compile without error?
Practice Language Fundamentals –
Which of the following would compile without error?
What is the value of “d” after this line of code has been executed?
Practice Language Fundamentals –
What is the value of “d” after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );
Which of the following is/are legal method declarations?
Practice Language Fundamentals –
Which of the following is/are legal method declarations?
protected abstract void m1();
static final void m1(){ }
synchronized public final void m1() { }
private native void m1();
Practice Language Fundamentals –
What will be the output of the program?
public class Test {
public int aMethod() {
static int i = 0;
i++;
return i;
}
public static void main(String args[]) {
Test test = new Test();
test.aMethod();
int j = test.aMethod();
System.out.println(j);
}
}
Practice Constructors and Destructors –
What will be the output of the program?
class A {
public A(int x){ }
}
class B extends A { }
public class test {
public static void main (String args []) {
A a = new B();
System.out.println("complete");
}
}
Which two are valid constructors for Thread?
Practice Threads –
Which two are valid constructors for Thread?
Which of the following statements is true?
Practice Assertions –
Which of the following statements is true?
Which statement is true about assertions in the Java programming la
Practice Assertions –
Which statement is true about assertions in the Java programming language?
Which statement is true?
Practice Assertions –
Which statement is true?
Which of the following statements is true?
Practice Assertions –
Which of the following statements is true?
x = 0;
if (x1.hashCode() != x2
Practice Declarations and Access Control –
x = 0;
if (x1.hashCode() != x2.hashCode() )
x = x + 1;
if (x3.equals(x4) )
x = x + 10;
if (!x5.equals(x6) )
x = x + 100;
if (x7.hashCode() == x8.hashCode() )
x = x + 1000;
System.out.println("x = " + x);
and assuming that the equals() and hashCode() methods are property implemented, if the output is “x = 1111“, which of the following statements will always be true?
Which two statements are true about comparing two instances of the
Practice Declarations and Access Control –
Which two statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden?
Which of the following statements about the hashcode()
Practice hashCode() method –
Which of the following statements about the hashcode() method are incorrect?
class Test1 {
public int
Practice hashCode() method –
class Test1 {
public int value;
public int hashCode() {
return 42;
}
}
class Test2 {
public int value;
public int hashcode() {
return (int)(value^5);
}
}
which statement is true?