Sie sind auf Seite 1von 23

Year- 2008

1. Int I =2;

System.out.println (“welcome”+1+2);

The Output is –

I. Welcome 4
II. Welcome 12
III. Compiler error
IV. None of these

Ans – (ii)
2. Int x=2;
For(x=0;x<5;x++);
System.out.println(x);

The output is –
i. 01234
ii. 1234
iii. 234
iv. 5

Ans – (i)

3. String a=”3”;
System.out.println(a);

The output is –

i. 3
ii. A
iii. Compiler error
Iv runtime exception

Ans – (i)

4. Int a =2;
For( ; a<5 ; a++)
System.out.println(a);

The output is –

i. Compiler error
ii. Runtime execption
iii. Infinite loop
iv. 234

Ans – (iv)

5. Int arr[] = new int [3];


Arr[3]=7;
System.out.println(arr[3]);

The output is –
i. 3
ii. 7
iii. Compiler error
iv. Runtime exception

Ans – (iv)

6. In Java applet , stop() method can be invoked


i. Once
ii. Twice
iii. Many times
iv. Not at all

Ans – (i)

7. Dynamic method dispatcher is used full for


i. Resolving method overriding
ii. Resolving multilevel inheritance
iii. Resolving multiple inheritance anomaly
iv. None of these

Ans – (i)

8. JVM stand for


i. Java Virtual Machine
ii. Java visual Machine
iii. Java vision machine
iv. None of these

Ans – (i)

9. Strings a = “WBUT”
System.out.println (s.charAt(2));
The output is –
i. U
ii. Exception error
iii. 2
iv. B

Ans – (i)

10. What is the return type of read() method of InputStream class ?


i. String
ii. Void
iii. Float
iv. None of these

Ans – (i)

11. Consider the following statements :

Int a = 10 , b=15

a = ((a<b) ? (b+a) : (b-a));

what will be the value of a after executing these statements ?

i. 10
ii. 25
iii. 15
iv. 5

Ans – (ii)

12. Which of the Following Statement is true regarding Constructors ?


i. All cases must define a Constructor
ii. A constructor can be declared private
iii. A Constructor can return a value
iv. A Constructor must initialize all the fields of a class

Ans – (iv)
Year – 2009
1. Java bytecode is saved in files with names that end with
a. .class
b. .code
c. .java
d. .exe

Ans – (i)

2. An exception is
a. Run time error
b. Machine error
c. Compile time error
d. none of these

Ans – (i)

3. From the following which one is not java primitive data type ?
a. Byte
b. Boolean
c. Short
d. Variant

Ans – (d)

4. The ability to declare different methods with the same name in a class is known as –
a. Method Overloading
b. Method Overriding
c. Recursion
d. None of these

Ans – (a)

5. Which member function of class is used to create object of that class ?


a. Constructor
b. New
c. Object
d. None of these

Ans – (a)

6. How many default Constructor one can have in a class ?


a. 1
b. 4
c. 0
d. 2
Ans – (a)

7. The many catch clause can be try statement have without finally ?
a. One
b. Any number
c. Zero
d. None of these
Ans – (c )

8. Which class cannot be instantiated ?


a. Abstract
b. Public
c. Final
d. Protected
Ans – (a)

9. All exceptions in Java are subclass of


a. Throwable
b. Abstract
c. Error
d. Throw
Ans – (a)

10. Data input is


a. An abstract class defined in java.io
b. A class we can use to read primitive data types
c. An interface that defines methods to open files
d. An interface that define methods to read primitive data types
Ans – (d )

Year – 2010
1. Which of these is known as short – circuit and operator
a. &&
b. &
c. ? &
d. None of these
Ans – (a)

2. A constructor can be inherited using the keyword


a. Final
b. Static
c. Super
d. None of these
Ans – (c)
3. Int I =2 ;
System.out.println(“welcome“ +1+2);
The output is –
a. Welcome3
b. Welcome12
c. Compiler error
d. None of these
Ans – (b )
4. To inherit the an interface from a class we use the keyword
a. Extends
b. Implements
c. Both (a) & (b)
d. None of these
Ans – (b )

5. In java applet , ‘Stop() ‘ method can be invoked for a thread –


a. Once
b. Twice
c. Compiler error
d. Not at all
Ans – (a)

6. Dynamic method dispatcher is used for


a. Resolving method overriding
b. Resolving multilevel inheritance
c. Resolving multiple inheritance anomaly
d. None of these
Ans – (a)

7. JVM stand for –


a. Java Virtual Machine
b. Java Visual Machine
c. Java vision Machine
d. None of these
Ans – (a)

8. Each time we shift a value to the right using ‘>>’ operator it divide the value by –
a. 4
b. 2
c. 8
d. None of these
Ans – (b)

9. Which of the following statement is true regarding constructor ?


a. All cases must be define as a constructor
b. A constructor can be define private
c. A constructor can return a value
d. A constructor must initialized all the fields of a class
Ans – (d)

Year – 2011
1. String s = “s”
System.out.println (s);
The Output is –

a. S
b. “s”
c. Compiler error
d. Run time error
Ans – (a)

2. Consider the following statements :

Int a = 3 , b=2 ;

a = (a<b) ? (a+b) : (a-b) ;

what will be the output of a ?

a. 5
b. -1
c. 1
d. 3
Ans – ( c )

3. Consider the following statements :


Int a[ ] = new int [3];
a[3] = 7;
System.out.println ( a[3] );
The Output is –
a. 3
b. 7
c. compiler error
d. Run time error
Ans – (d)

4. Consider the following statements :


String s = “BCAE-602B”;
System.out.println (s.char At (2) );
The Output is –
a. C
b. A
c. Exception error
d. 2
Ans – (b)
5. Which class can not be initialized ?
a. Abstract
b. Public
c. Final
d. Protected
Ans – (a)

6. How many catch clause can try statement have ?


a. One
b. Any number
c. Zero
d. None of these
Ans – (a)

7. An exception is –
a. Run time error
b. Compiler error
c. Machine error
d. None of these
Ans – (a)

8. How many default constructor can a class have , when it has constructor ?
a. 1
b. 0
c. 2
d. Any number
Ans – (a)

9. The JVM complies a java source code to –


a. Object code
b. Executable code
c. Unicode
d. None of these
Ans – (b)

10. JRE stand for –


a. Java research Engine
b. Java Remote Engine
c. Java Runtime environment
d. None of these
Ans – ( c )
Year – 2012
1. A constructor –
a. Must have the same name as the class it is declared within
b. Is used to create objects
c. May be declared private
d. None of these
e. a,b,c
Ans – (a)

2. Which of the following may be part of a class definition ?


a. Instance variable
b. Instance methods
c. Constructors
d. All of these
Ans – (d )

3. What is the difference between a Java applet and a Java application ?


a. An application can in general be trusted whereas an applet can’t
b. An applet must be executed in a browser environment
c. An applet is not able to access the files of the computer it runs on
d. (a) , (b) and (c)
Ans – (d )

4. What is the byte code in the context of java ?


a. The type of code generated by java compiler
b. The type of code generate by java virtual machine
c. It is another name of java source file
d. It is the code written the instance methods of a class
Ans – (a)

5. What is the garbage collection in the context of java ?


a. The operating system periodically deletes all of the java files available on the system
b. Any package imported in a program and not used is automatically deleted
c. When all references to an object are gone , the memory used by the object is
automatically reclaimed
d. The JVM checks the output of any Java program and deletes anything that doesn’t
make sense.
Ans – ( c )

6. Consider the following code snippet


String river = new string (“Columbia”)
System.out.println (river.length());

What is printed ?

a. 6
b. 7
c. 8
d. Columbia
e. River
Ans – (b)

7. You read the following statement in a java program that compiles and executes
Submarine.drive(depth);
What can you say for sure ?
a. Depth must be an int
b. Drive must be a method
c. Drive must be the name of an instance field
d. Submarine must be the name of class
e. Submarine must be a method
Ans – (b)

8. Consider the following program :


Import myLibrary. *;
Public class ShowSomeClass
{

// code for the class

}
What is the name of the java file containing this program ?
a. myLibrary.Java
b. ShowSomeClass.java
c. ShowSomeClass
d. ShowSomeClass.Class
e. Any file name with the java suffix will do
Ans – (b)

9. Which of the following is TRUE ?


a. In java , an instance filed declared public generates a compilation error
b. Int is the name of a class available in the package java.lang
c. A class has always a constructor ( possibly automatically supplied by the java
compiler)
d. A class has always a constructor (possibly automatically supplied by the java
compiler )
e. The more comments in a program in a program , the program runs.
Ans – ( d)

10. What is the full form of JVM ?


a. Java Visual Machine
b. Java Variable Management
c. Java Virtual Machine
d. None of these
Ans – (c )
Year – 2013
1. JVM stand for –
a. Java Virtual Machine
b. Java Vision Machine
c. Java Visual Machine
d. None of these
Ans – (a)

2. String str = “ABCD”


System.out.println (str.chrAt (2));
The output is –
a. C
b. 2
c. Exception occurs
d. None of these
Ans – ( a)

3. Dynamic method dispatcher is used full for


a. Resolving method overriding
b. Resolving multilevel inheritance
c. Resolving multiple inheritance anomaly
d. None of these
Ans – (a)

4. In Java applet , stop () method can be invoked


a. Once
b. Twice
c. Many times
d. Not at all
Ans – (a )

5. Which of the following statements is true regarding constructors ?


a. All cases must be define as a constructor
b. A constructor can be define private
c. A constructor can return a value
d. A constructor must initialized all the fields of a class
Ans – (d )

6. What is the return type of read () method of InputStream class ?


a. String
b. Float
c. Void
d. None of these
Ans – (a )

7. Which of the following JSP expression are valid ?


a. <%=”Sorry”+”for the “+”break”%>
b. <%=”Sorry”+”for the “+”break” ; %>
c. <%=”Sorry” %>
d. <%=”Sorry” ; %>
Ans – ( b )

8. A class can be converted to a thread by implementing the interface


a. Thread
b. Runnable
Ans – (b )

9. Which is not allowed in EJB programming ?


a. Thread management
b. Transient fields
c. Listening on a socket
Ans – (a)

10. What happens if Database Updation code is written code is written in ejbPassivate() method
and if this method is called ?
a. Exception is thrown
b. Successfully execute the database updation code
c. Compilation error occurs indicating that database updation cod should not be
written in ejbpassivate ()
d. ejbStore () method is called
Ans – (a)

Year – 2014
1. A class can have many methods with the same name as long as the number of the
parameters or type of parameters is different. This OOP concept is know as -------
a. Method invocating
b. Method overriding
c. Method labelling
d. Method overloading
Ans – (d )

2. What keyword is used in java to define a constant –


a. Static
b. Final
c. Abstract
d. Public
e. Private
Ans – (a) & (b)

3. Which one of the following methods keeps the thread t in run state ?
a. t.start()
b. t.run()
c. t.setRun()
d. t.stop –()
Ans – (a)

4. Color clr = new Color (Color.red);


The above statement produces same intensity of red color on any color monitor as Java is
Platform independent.
a. True .
b. False
Ans – (b)

5. What is the most expensive phase in a software development life cycle


a. Design
b. Maintenance
c. Implementation
d. Analysis
e. Testing
Ans – ( e )

6. What is the width of the line that drawLine() method draws ?


a. 1 pixel
b. 2 pixel
c. 3 pixel
d. 4 pixel
e. None
Ans – (a)

7. Java was developed by the company


a. Sun Micro system
b. Microsoft
c. Micro tech
d. IBM
Ans – (a)

8. ---------------------- keyword is used to invoke the current object.


a. New
b. That
c. This
d. Me
Ans – (c )

9. What is the default return type of main ( )


a. Void
b. Double
c. Float
d. Int
Ans – (d )

10. Method overloading is one of the way that java supports _________________
a. Encapsulation
b. Class
c. Inheritance
d. Polymorphism
Ans – (d )

Year – 2015
1. Which is reserved word in the java programming language ?
a. Method
b. Native
c. Subclass
d. Reference
Ans – (b )

2. What is byte code in the context of java ?


a. The type of code generated by a java compiler
b. The type of code generated by java virtual machine
c. It is another name for a Java source file
d. It is the code written within the instance methods of a class
Ans – (a)

3. Which of the following statements is correct ?


a. The ‘try’ block should be followed by the a ‘catch’ block
b. The ‘try’ block should be followed by a ‘finally’ block
c. The ‘try’ block should be followed by either a ‘catch’ block or a ‘finally’ block
d. The ‘try’ block should be followed by at least two ‘catch’ blocks
Ans – (a )

4. JVM stand for ________


a. Java Virtual Machine
b. Java Visual Machine
c. Java Vision machine
d. None of these
Ans – (a)

5. To inherit an class form a class , we use the keywords


a. Extends
b. Implements
c. Both (a) & (b)
d. Done of these
Ans – (a )

6. An Interface can define only


a. Abstract class
b. Final field
c. Abstract method
d. Abstract method and final field
Ans – (d)

7. In Java applet , stop () method can be invoked


a. Once
b. Twice
c. Many times
d. Not at all
Ans – (A)

8. An exception is a / an
a. Runtime problem
b. Compile time problem
c. Entity dependent on type
d. None of these
Ans – (A)

9. Which keyword is used in Java to define a constant


a. Static
b. Final
c. Public
d. None of these
Ans – (a) & (b)

10. Strings a = “WBUT”


System.out.println (s.charAt(2));

The output is –
a. U
b. Exception error
c. 2
d. B

Ans – (a)

Year – 2016
1. Return type of a constructor method is -
a. Int
b. Void
c. Class type itself
d. Nothing, as no specification of return type is needed
Ans – (d)

2. Which of the following is used as a part of method signature in java ?


a. Throw
b. Try
c. Throws
d. Finally
Ans – (a )

3. Which one of the following is not true about an interface ?


a. A particular class can be implement several interfaces
b. It can be implemented by an interface
c. It can be implemented by several classes.
d. It can be partially implemented by a class.
Ans – (d)

4. “String Buffer “ differs from “string” in the sense that


a. String Buffer is used only to buffer data from an input or output.
b. String Buffer allows text to be changed after instantiation
c. String buffer holds zero strings
d. String buffer supports Unicode.
Ans – (d)

5. Which of the following cannot be used as a method modifier ?


a. Private
b. Generic
c. Protected
d. Synchronised
Ans – (a)

6. Which of the following is not a reserved word in Java ?


a. Transient
b. Implement
c. Include
d. Instance of
Ans – ( c )

7. A top level of class without any modifier is accessible to


a. Any class
b. Any class within the same package
c. Any class with same file
d. Any subclass of this class
Ans – (b)
8. What will be the result of running the following method with an input of 2 ?

Public int Adder( int n ) {

Return 0 x 100 + ++n;

a. The method will return 259


b. The method will return 103
c. The method will return 260
d. The method will return 104
Ans – (a)

9. Which of the following is used to detect the selection made by user on a choice component?
a. Action listener
b. Item listener
c. Mouse listener
d. Selection listener
Ans – ( c )

10. Contract of a class is meant by –


a. Number of methods in the class
b. Number of data fields in the class
c. Number of construction in the class
d. None of these
Ans – ( a )

Year – 2017
1. Int x=2;
For ( x=0 ; x<5 ; x++ )
System.out.println (x);
The output is –
a. 01234
b. 234
c. 1234
d. None of these
Ans – (a)

2. How many default constructor can a class have when it has constructor ?
a. 1
b. 0
c. 2
d. Any number
Ans – (1)

3. Consider the following statement :


Int a = 10 , b=15 ;
a = (a < b ) ? ( b+ a) : ( b - a ) ;
what will be the value of after executing these statements ?
a. 10
b. 25
c. 15
d. 5
Ans – (b )

4. A constructor can be inherited using the keyboard


a. Final
b. Static
c. Super
d. None of these
Ans – ( c )

5. Method overloading is one of the way that java supports


a. Encapsulation
b. Class
c. Inheritance
d. Polymorphism
Ans – (d )

6. Which access modifier is used to restrict the methods scope to itself and still allows other
classes to subclass that class ?
a. Private
b. Final
c. Protected
d. Public
Ans – (b )

7. An exception is a / an –
a. Runtime problem
b. Compile time problem
c. Entity dependent on type
d. None of these
Ans – (a )

8. An inheritance can define only


a. Abstract class
b. Final fields
c. Abstract method
d. Abstract method and final field
Ans – (A)

9. In Java applet , start () method may be invoked


a. Once
b. Twice
c. Many times
d. Not at all
Ans – (a)

10. A constructor –
a. Must have the same name as the class it is declared within
b. Is used to cerate objects
c. May be declared private
d. None of these
Ans – (a) , (b)

11. Runnable interface is used for


a. Creating child thread
b. Creating main thread
c. Creating both (a) & (b)
d. None of these
Ans – ( c )

Year – 2018
1. Which type of polymorphism is nothing but the method overloading in java ?
a. Compile time polymorphism
b. Runtime polymorphism
c. Static polymorphism
d. Both (a) & (b)
Ans – (a)

2. Which of the following is true about access modifier ?


a. Variable , method and constructors which are declared private can be accessed only
by the members of the same class .
b. Variables method and constructor which are declared private can be accessed by
any class lying in same package.
c. Variable , method and constructors which are declared private in the superclass can
be accessed only by its child class
d. None of these
Ans – (a)

3. Which of the following regarding abstract classes are true ?


a. An abstract class be extended .
b. A subset of a non – abstract super class can be abstract
c. A superclass can override a concrete method in a superclass to declare it abstract
d. An abstract class can be used as a data type .
e. All of these
Ans – (e )

4. Which of the following is a correct interface ?


a. Interface A { void print () }
b. Abstract interface A {print() ; }
c. Abstract interface A { abstract void print (); [] }
d. Interface A [void print () ; ]
Ans – (d)

5. Dynamic method is dispatcher is used for –


a. Resolving method overriding
b. Resolving multilevel inheritance
c. Resolving multiple inheritance
d. None of these
Ans – (a)

6. What is runtime polymorphism ?


a. Runtime polymorphism is a process in which a call to an overridden method is
resolved at runtime rather than at compile – time .
b. Runtime polymorphism is a process in which a call to an overloaded method is
resolved at runtime rather than at compile -time .
c. Both (a) & (b)
d. None of these.
Ans – (a)

7. Which of the following is the main use of package ?


a. Categories data
b. Make compiling factor
c. Resolve name conflicts
d. None of these
Ans – ( c )

8. Which method used in thread class to test if the current thread class to test if the current
thread has been interrupted ?
a. Public static Boolean interrupted ()
b. Public Boolean is interrupted ()
c. Public void interrupted
d. Public Boolean is Alive ()
Ans – (a)

9. Which are also known as inner classes ?


a. Non – static nested class
b. Static nested class
c. Nested class
d. Nine of these
Ans – (a)

10. An exception is –
a. Runtime error
b. Machine error
c. Compile time error
d. None of these
Ans – (a)

Year – 2019
1. Which of the following may be part of a class definition ?
a. Instance variables
b. Instance methods
c. Constructors
d. All of these
Ans – (d)

2. How many default constructors can a class have ?


a. One
b. Two
c. More than one
d. None of these
Ans – (A)

3. An exception is
a. A runtime error
b. A compile time error
c. A syntactical error
d. None of these
Ans – (A)

4. Full Form of JVM is -


a. Java Visual Machine
b. Java virtual machine
c. Java Variable Management
d. None of these
Ans – (b)

5. Consider the following program :


Import java.io.*;
Public class TestClass {
Public static void main (string [] args){
// method body
}

What should be the name of the program ?

a. TestClass.class
b. TestClass.java
c. TestClass.obj
d. None of these
Ans – (b)

6. Consider the following statement :


Int a=5, b=6;
Int y = ( a < b ) ? (b -- ) : (a--);
What should be the value of y after the execution of the above statements ?
a. 5
b. 6
c. Compiler time error
d. Run time error
Ans – (5)

7. JRE stand for –


a. Java Runtime Environment
b. Java Resource Environment
c. Java Runtime Entity
d. None of these
Ans – (a)

8. What invokes a thread’s run () method ?


a. JVM invokes the thread’s run () when the thread is initially executed
b. Main application running the thread
c. Start () method of the thread class
d. None of these
Ans – ( c )

9. When does finally block get executed ?


a. Always when try block get executed , no matter exception occurred or not
b. Only when exception occurs in try block code
c. Always when exception occurs in try block code
d. Always when a try block get executed , if exception do not occur .
Ans – (d)

10. Which class cannot be initialized ?


a. Abstract
b. Final
c. Public
d. Protected
Ans – (a) & (b)

11. Which of the following is not supported in Java ?


a. Multilevel inheritance
b. Multiple inheritance
c. Hierarchical inheritance
d. None of these
Ans – (b)
12. Consider the following code segment :
Class Test {
Int x =10;
Public static void main (string [] args ){
Test t = new Test ();
System.out.println (t.x);
}
}
What should be the output of the above codec?
a. 10
b. 0
c. Run Time error
d. None of These
Ans – 10

Das könnte Ihnen auch gefallen