Javac

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 9

A#Q1.

Which of these keywords is used to


define packages in Java?
A. pkg
B. Pkg
C. package
D. Package
A#Q1ANS= C
A#Q2. Which of these is a mechanism for
naming and visibility control of a class
and its content?
A. Object
B. Packages
C. Interfaces
D. None of the Mentioned.
A#Q2ANS=B
A#Q3. Which of this access specifies can
be used for a class so that its members
can be accessed by a different class in
the same package?
A. Public
B. Protected
C. No Modifier
D. All of the mentioned
A#Q3ANS=D
A#Q4. Which of these access specifiers can
be used for a class so that it�s members can be
accessed by a different class in the different package?
A. Public
B. Protected
C. Private
D. No Modifier
A#Q4ANS=A
A#Q5. Which of the following is correct way of
importing an entire package �pkg�?
A. import pkg.
B. Import pkg.
C. import pkg.*
D. Import pkg.*
A#Q5ANS=C
A#Q6. Which of the following is incorrect statement
about packages?
A. Package defines a namespace in which classes 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.
A#Q6ANS=D
A#Q7. Which of the following package stores all
the standard java classes?
A. lang
B. java
C. util
D. java.packages
A#Q7ANS=B
A#Q 8. What is the output of this program?
1. package pkg;
2. class display {
3. int x;
4. void show() {
5. if (x > 1)
6. System.out.print(x + " ");
7. }
8. }
9. class packages {
10. public static void main(String args[]) {
11. display[] arr=new display[3];
12. for(int i=0;i<3;i++)
13. arr[i]=new display();
14. arr[0].x = 0;
15. arr[1].x = 1;
16. arr[2].x = 2;
17. for (int i = 0; i < 3; ++i)
18. arr[i].show();
19. }
20. }
A. 0
B. 1
C. 2
D. 0 1 2
A#Q8ANS=C
A#Q 9. What is the output of this program?
1. package pkg;
2. class output {
3. public static void main(String args[])
4. {
5. StringBuffer s1 = new StringBuffer("Hello");
6. s1.setCharAt(1, x);
7. System.out.println(s1);
8. }
9. }
A. xello
B. xxxxx
C. Hxllo
D. Hexlo
A#Q9ANS=C
A#Q10. What is the output of this program?
1. package pkg;
2. class output {
3. public static void main(String args[])
4. {
5. StringBuffer s1 = new StringBuffer("Hello World");
6. s1.insert(6 , "Good ");
7. System.out.println(s1);
8. }
9. }
A. HelloGoodWorld
B. HellGoodoWorld
C. Compilation error
D. Runtime error
A#Q10ANS=D
A#Q11. Which of these packages contain all the collection classes?
A. java.lang
B. java.util
C. java.net
D. java.awt
A#Q11ANS= B
A#Q12. Which of these classes is not part of
Java�s collection framework?
A. Maps
B. Array
C. Stack
D. Queue
A#Q12ANS=D
A#Q13. Which of these interface is not a part of Java�s
collection framework?
A. List
B. Set
C. SortedMap
D. SortedList
A#Q13ANS=D
A#Q14. Which of these methods deletes all the elements from
invoking collection?
A. clear()
B. reset()
C. delete()
D. refresh()
A#Q14ANS=A
A#Q15. What is Collection in Java?
A. A group of objects
B. A group of classes
C. A group of interfaces
D. None of the mentioned
A#Q15ANS=A
A#Q16. What is the output of this program?
import java.util.*;
class Array {
public static void main(String args[]) {
int array[] = new int [5];
for (int i = 5; i > 0; i--)
array[5-i] = i;
Arrays.fill(array, 1, 4, 8);
for (int i = 0; i < 5 ; i++)
System.out.print(array[i]);
}
}
A. 12885
B. 12845
C. 58881
D. 54881
A#Q16ANS=C
A#Q17. What is the output of this program?
import java.util.*;
class vector {
public static void main(String args[]) {
Vector obj = new Vector(4,2);
obj.addElement(new Integer(3));
obj.addElement(new Integer(2));
obj.addElement(new Integer(5));
obj.removeAll(obj);
System.out.println(obj.isEmpty());
}
}
A. 0
B. 1
C. true
D. false
A#Q17ANS=C
A#Q16. class exception_handling {
2. public static void main(String args[]) {
3. try {
4. int a, b;
5. b = 0;
6. a = 5 / b;
7. System.out.print("A");
8. }
9. catch(ArithmeticException e) {
10. System.out.print("B");
11. }
12. finally {
13. System.out.print("C");
14. }
15. }
16. }
A.A
B. B
C. AC
D. BC
A#Q16ANS=D

B. [3, 2]
C. [3, 2, 5]
D. [3, 5, 2]
A#Q18ANS=A

A#Q19ANS=B
A#Q17. What is the output of this program?
import java.util.*;
class Bitset {
public static void main(String args[]) {
BitSet obj = new BitSet(5);
for (int i = 0; i < 5; ++i)
obj.set(i);
obj.clear(2);
System.out.print(obj);
}
}

A. {0, 1, 3, 4}
B. {0, 1, 2, 4}
C. {0, 1, 2, 3, 4}
D. {0, 0, 0, 3, 4}
A#Q17ANS=A

A#Q18. Which of these interface is not a part of Java�s


collection framework?
A. List
B. Set
C. SortedMap
D. SortedList
A#Q18ANS=D

A#Q19.Which of these is an incorrect form of using


method max() to obtain maximum element?
A. max(Collection B.
B. max(Collection c, Comparator comp)
C. max(Comparator comp)
D. max(List B.
A#Q19ANS=D

A#Q20.Which of these access specifiers can be used for an interface?


A. Public
B. Protected
C. private
D. All of the mentioned

A#Q20ANS=D

A#Q21. Which of these keywords is not a part of exception handling?


A. try
B.
finally
C. thrown
D. catch
A#Q21ANS=C
A#Q22. Which of these process occur automatically
by java run time system?
A. Serialization
B. Garbage collection
C. File Filtering
D. All of the mentioned

A#Q20ANS=A

A#Q23. Which of these is a method of ObjectOutput


interface used to finalize the output state so that
any buffers are cleared?
A. clear()
B. flush()
C. fflush()
D. close()
A#Q23ANS=B

A#Q24.Modulus operator, %, can be applied to which of these?


A. Integers
B. Floating � point numbers
C. Both Integers and floating � point numbers.
D. None of the mentioned

A#Q24ANS=A

A#Q25.Given the following piece of code:


public class School
{
public abstract double numberOfStudent();
}
which of the following statements is true?
A.The keywords public and abstract cannot be used together.
B.The method numberOfStudent() in class School must have a body.
C.You must add a return statement in method numberOfStudent().
D.Class School must be defined abstract.
A#Q25ANS=D
A#Q26.Which mechanism is used when a thread is
paused running in its critical section and another
thread is allowed to enter (or lock)
in the same critical section to be executed?

A. Inter-thread communication
B. Initial-thread communication
C. Mutual Exclusive
D. None of the above
A#Q26ANS=A

A#Q27. What can be accessed or inherited without actual


copy of code to each program?

A. Browser
B. Applet
C. Package
D. None of the above

A#Q27ANS=C

A#Q28.Which is the container that doesn't contain title baR


and MenuBars but it can have other components like button,
textfield etc?

A. Window
B. Frame
C. Panel
D. Container

A#Q28ANS=C

A#Q29.Give the abbreviation of AWT?

A. Applet Windowing Toolkit


B. Abstract Windowing Toolkit
C. Absolute Windowing Toolkit
D. None of the above

A#Q29ANS=B

A#Q30.What will be printed as the output of


the following program?
public class testincr
{
public static void main(String args[])
{
int i = 0;
i = i++ + i;
System.out.println("I = " +i);
}
}
A. I = 0
B. I = 1
C. I = 2
D. Compile-time Error.

A#Q30ANS=B
A#Q31.Which of the following is true?
A.A finally block is executed before the catch block
but after the try block.
B.A finally block is executed, only after the catch
block is executed.
C.A finally block is executed whether an exception is thrown or not.
D.A finally block is executed, only if an exception occurs.

A#Q31ANS=C

A#Q32.What modifier is to be used If you wish to declare that


you want to no longer allow subclasses to override your
variables or methods?
(a)Finally
(B.Volatile.
(B.Final
(B.Synchronized

A#Q32ANS=C

A#Q33.What is the output of the following program?

interface OuterInterface
{
public void InnerMethod();
public interface InnerInterface
{
public void InnerMethod();
}
}
public class Outer implements OuterInterface.InnerInterface, OuterInterface
{
public void InnerMethod()
{
System.out.println(100);
}

public static void main(String[] args)


{
Outer obj = new Outer();
obj.InnerMethod();
}
}

A. 100
B. Compilation Error
C. Runtime Error
D. None of the above

A#Q33ANS=A

A#Q34.Which is a mechanism where one object acquires


all the properties and behaviors of the parent object?

A. Inheritance
B. Encapsulation
C. Polymorphism
D. None of the above
A#Q34ANS=A

A#Q35.Which is a superclass of all exception classes?

A. Throwable
B. Exception
C. RuntimeException
D. IOException
A#Q35ANS=A

A#Q36. JDBC is a ������� interface, which means that it is used to invoke SQL
commands directly

A) low-level

B. middle-level

C. higher-level

D. user
A#Q36ANS=A
A#Q37. ODBC is not appropriate for direct use from java because it uses a ����..

A. C interface

B. C# interface

C. java interface

D. Both A and C
A#Q37ANS=A
A#Q38. Java Soft provides �����.. JDBC product components as part of the java
Developer�s Kit (JDK)

A. three

B. two

C. four

D. single
A#Q38ANS=A
A#Q39. Kind of driver converts JDBC calls on the client API for Oracle, Sybase,
Informix, DB2, or other DBMS is known as

A. JDBC-Net pure Java driver

B. JDBC-ODBC Bridge plus ODBC driver

C. Native-API partly-Java driver

D. Both A and B
A#Q39ANS=C
A#Q40.If an expression contains double, int, float, long, then whole expression
will promoted into which of these data types?
A. long
B. int
C. double
D. float
A#Q40ANS=C

You might also like