Basics of Java Programming (Classes and Objects).

POST TEST :


Question 1:
What is the output of this program?
class A {
int i;
int j;
A(){
i = 1;
j = 2;
}
}
class Output {
public static void main(String args[]){
A obj1 = new A();
A obj2 = new A();
System.out.print(obj1.equals(obj2));
}
}

false
true
1
Compilation Error


Question 2:
What is the output of this program?
class Output {
public static void main(String args[]){
Object obj = new Object();
System.out.print(obj.getclass());
}
}

Object
class Object
class java.lang.Object
Compilation Error


Question 3:
What is the output of this program?
class A {
int i;
int j;
A() {
i = 1;
j = 2;
}
}
class Output {
public static void main(String args[]){
A obj1 = new A();
System.out.print(obj1.toString());
}
}

true
false
String associated with obj1
Compilation Error


Question 4:
In object-oriented programming, new classes can be defined by extending existing classes. This is an example of?
Encapsulation
Interface
Composition
Inheritance


Question 5:
Which of these class is superclass of every class in Java?
String class
Object class
Abstract class
None of the above.


Question 6:
What is the process of defining a method in terms of itself, that is a method that calls itself?
Polymorphism
Abstraction
Encapsulation
Recursion


Question 7:
Which of the following is an invalid declaration for the main method in java program?
public static void main (String [ ] args)
public static strictfp void main(String args[ ])
final static public void main (String args[ ]
All are Correct


Number of score out of 7 = Score in percentage =