CoreJava2
CoreJava2
public test()
{
setLayout(new FlowLayout());
add(bsouth);
add(bwest);
add(beast);
add(bnorth);
add(bcenter);
setLayout(new BorderLayout());
validate();
setSize(300,300);
setVisible(true);
}
}
}
1: class Test
2: {
3: static void show()
4: {
5: System.out.println("Static method in Test");
6: }
7: }
8: public class Q4 extends Test
9: {
10: void show()
11: {
12: System.out.println("Overridden static method in Q4");
13: }
14: public static void main(String[] args)
15: {
16: }
17: }
1. Compilation error at line 3.
2. Compilation error at line 10.
3. No compilation error, but runtime exception at line 3.
4. No compilation error, but runtime exception at line 10.
Correct Answer : 2
Your Answer : 1
QuestionID : 9906 Subject Name Core Java
Q33. The following code will print
class First {
System.out.println(s);
new Second();
1. Nothing happens
2. A string is printed to the standard out
3. An instance of the class First is generated
4. The class second will not compile as there is no null parameter
constructor in the class First
Correct Answer : 4
Your Answer : 2
QuestionID : 10162 Subject Name Core Java
Q41. What is the result of compiling and running the following code:
new Test();
public Test () {
System.out.println("In test");
System.out.println(this);
if (temp > 5) {
System.out.println(temp);
System.out.println(4.0/0.0);
1. -Infinity
2. Infinity
3. Compile time error
4. Will throw exception
Correct Answer : 2
Your Answer : 4
QuestionID : 10248 Subject Name Core Java
Q46. class A
{
public static void main(String[] args)
{
String str="ram-shyam";
System.out.println(str.substring(4,10));
}
}