Tag: java
Questions Related to java
Which two are true about the objects created within main(), and eligible for garbage collection when line 14 is reached?
What will be the output?
package inheritance;
class TestInheritance4 {
String name = "JAVA";
}
package inheritance1;
import
import inheritance.TestInheritance4;
public class TestInheritance_4 extends TestInheritance4 {
void printName() {
System.out.println("name =" + name);
}
public static void main(String[] args) {
TestInheritance_4 T_4 = new TestInheritance_4();
T_4.printName();
}
}
Syntax of System.arraycopy
method??
int x = 10;
do {
x--;
} while (x < 10);
How many times the loop will be executed?
int x = 0;
int y = 10;
do {
y--;
++x;
} while (x < 5);
System.out.print(x + "," + y);
What is the result?
String[] elements = {
"for",
"tea",
"too"
};
String first = (elements.length > 0) ? elements[0] : null;
What is the result?