Tuesday, January 26, 2010

III. Each Question Carries 4 Mark.

1) What is the output ?
class MyStatic
{
static int y;
static void show(){ System.out.println("y = "+y);
}
class demo
{ public static void main(String args[])
{
MyStatic.y = 10;
MyStatic.show();
}
}

a) 10 b) Run Time Error c) Compile time Err d) None

2) Methods are defined as
i) Return type ii) Name of the Method
iii) A list of Parameters iv) Body of the method

a) one i b) ii, iii c) all d) None

3) Select true statements
i) When a variable is referred with in a method, java checks for the definition of the variable.
ii) if the variable is not local variables, that is if it is not defined within the current method
then java checks for the definition of that variable as an instance or class variables.
a) only i b) only ii c) Both d) None



4) i.) The lack of static key word in fornt of a method makes it an instance method.
ii) java supplies wrapper classes for each of the basic data types.
iii) The wrapper classes provide class methods to perform conversions from object to primitive data type and vice versa.
a) i. b) ii c) All d) None

5) class A
{ private int a; protected int b; public int c; }
class B extends A { }
in class B how many variables can be accessed.
a) only one b) only two c) All d) None

6) Select true statements
i) function overloading is nothing but the number of arguments or the type of arguments are to be different for creating two or
more methods with the same name.
ii) The return types of the methods can be different as long as the method signature is different.
iii) When the same method name is used in both the subclass and super class with the same signature is called function
overriding.
a) i, ii b) ii , iii c) i, ii, iii d) None

7) i) constructor methods have the same name as the name of the class
ii) constructor does not return a value
iii) it can be overloaded
iv) Typically they are used to set initial values to instance variables
a) i, ii b) i, ii, iii c) All d) None

8) i) The key word extends is used to implement inheritance.
ii) The key word extends is followed by name of the super class
iii) In Java Object class is at the top of the hierarchy of the classes.
a) only I b) only ii c) All d) None

9) i) a package is collection of classes and interfaces
ii) java.io package contains classes and interfaces for various kinds of input and out.
iii) package defines a boundary to see how classes and interfaces interact with one another.
a) only i b) only iii c) i, ii, iii d) None

10) i) classpath variable plays significant role in locating classes.
ii) if class path is not set, java will look for the classes in the current directory and the default directory.
iii) if class path is specified then java will look those directories which are specified with class path.
a) i, ii, iii b) only i c) only i, ii d) None

III. Answer – 4 Mark.

1. A 2. A 3. C 4. B 5. B 6. C 7. C
8. C 9. C 10. A