Category Archives: JAVA Lang. Skills

CLST3 : JAVA

Que 1.) Which of the following is correct way of importing an entire package ‘pkg’?
A) import pkg.
B) Import pkg.
C) import pkg.*
D) Important pkg.*

Que 2.) Which of the following is incorrect statement about packages?
A) Package defines a namespace in which class are stored.
B) A package can contain other package within it.
C) Java uses file system directories to store packages.
D) A package can be renamed without renaming the directory in which the classes are stored.

Que 3.) Which of the following package stores all the standared java classes ?
A) lang
B) java
C) util
D) java.packages

Que 4.) Which of these access specifiers can be used for a class so that it’s member can be accessed by a different class in different package ?
A) Public
B) Protected
C) Private
D) No Modifier

Que 5.) Which of these package is used for analyzing code during run-time?
A) java.applet
B) java.awt
C) java.io
D) java.lang.reflect Reflection is the ability of a software to analyze itself.This is provided by java.lang.reflect package.

Que 6.) You want subclasses in any package to have access to members of a superclass.Which is the most restrictive access that accomplishes this objective?
A) private
B) transient
C) public
D) protected

Que.7) Outcome of test() will be :

void test()
{
int[] a={2,1};
short i = 0;
System.out.println(a[i]);
}

A) 2
B) Runtime error
C) Compile error
D) 1

Que.8) Which of the following inheritance type is not allowed in java ?
A) Multilevel
B) Multiple
C) Hierarchical
D) All are allowed
Que.9) What is true regarding method overriding ?

A) Also called Dynamic Polymorphism
B) if method is inherited only then it can be overridden
C) final method can’t be overridden
D) All of above

Que.10) What is output of following program ?

public class Collections
{
public static void main(String[] args)
{
List list=new ArrayList();
list.add("X");
list.add("Y");
list.add(new int[10]);
System.out.println(list);
}
}

A) [X,Y,10]
B) [X,Y]
C) Compile time error
D) Runtime error

Answers :->

Continue reading CLST3 : JAVA

CLST2 : JAVA

Q1.) Boolean values can be cast into any other primitive type.
A) True
B) False

Q2.) Can we overload a static method ?
A)Yes                                        B)No
C)Depend on the program requirement
D)None of these

Q3.)  What will be the output of the program ?
public class Test {
public static void main(String[] args)
{
int x;
System.out.println(x);
}
}

A) 0
B) 1
C) Compile-time error(s)
D)RunTimeException

Q4.) What will be the output of the program?
public class Test {
static int x =1;
public static void main(String[] args)
{
System.out.println(x–);
}
}

A)0                                       B)1
C)Compile-time error(s)  D)RunTimeException

Q5.) What will be the output of the program?
class C{
static int f1(int i)
{
System.out.print(i + “,”);
return 0;
}
public static void main (String[] args) {
int i = 0;
i = i++ + f1(i);
System.out.print(i);
}
}

A)0, 0                B)1, 0                  C)0, 1
D)Compile-time error(s)             E)None of the above

Q6.) If you access an uninitialized instance variable what will result?
A)Syntax Error                               B)Compile-time Error
C)RunTime Error                          D)No Error

Q7.) What will be the output of the following program?
public class Test {
public static void main(String[] ar) {
System.out.println(ar.length);
}
}

A)0
B)Compile-time error(s)
C)Null Pointer Exception
D)None of these

Q8.) Which among the following are known as short circuit operator ?
A) | and ||                                        B) & and &&
C) || and &&                                   D) | and &

Q9 .)   Can we declare a method as final without declaring it’s enclosing
class as final?
A) Yes                                              B)No

Q10. ) Which of the following statement is true?
A)External class can be declared as protected
B)We can define a method with the same name as class
C)Constructor can be declared as static.
D)Parameters can’t be defined in Constructor signature

Answers :-

Continue reading CLST2 : JAVA

CLST 1:

Q1: Which of the following are valid comments?
1.   /* comment /
2.  / comment
3.  // comment
4.  */ comment */

Q2: Arrange the operators given below in order of higher precedence to lower precedence.
1. &&                   2. %
3. >=                    3. ++

Q3: Identify the statements listed below as assignments, increment, method invocation or object creation statements.
1. System.out.println(“JAVA”) ;
2. costPrice = 45.20 ;
3. Car hybrid = new Car() ;
4. price++ ;

Q4: State one difference between floating point literals float and double.

Q5: Name the primitive data types in java that is:
1: A 64-bit integer and is used when you need a range of values wider than those provided by int.
2. A single 16-bit Unicode character whose default value is ‘\u0000’ ?

Q6: What is meant by a package ? Name any two Java Application Programming Interface packages.

Answers —–>
Continue reading CLST 1: