Documente Academic
Documente Profesional
Documente Cultură
runtime arguments
class sample
{
public static void main(String args[])
{
try
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
int c = a + b;
System.out.println("Sum is "+c);
}
catch(ArithmeticException ae)
{ System.out.println("Arithmetic Exception "+ae.getMessage()); }
catch(NumberFormatException ne)
{ System.out.println("Number Format Exception "+ne.getMessage()); }
catch(Exception e)
{ System.out.println("Exception "+e); }
}
}
Choice a
ArithmeticException
Choice b
NumberFormatException
Choice c
Exception
Choice d
None of the above
[2] In Java, when a run-time error occurs which of the following may happen
Choice a
compiles successfully
Choice b
produces wrong output
Choice c
abnormal termination
Choice d
All of the above
[3] In Java, which Exception type is caused by an attempt to access a nonexistent file
Choice a
FileNotFoundException
Choice b
IOException
Choice c
InvalidFileException
Choice d
IOException
[4] In Multithreaded programming, which method is used to transfer control to another
thread of equal priority before its turn comes
Choice a
yield()
Choice b
resume()
Choice c
wait()
Choice d
notify()
[5] To create a package what is the first statement included?
Choice a
import java.aw+.*;
Choice b
package
Choice c
public
Choice d
Class
[6] Which of the following step is invalid for creating a package
Choice a
Declare the package in beginning of the file
Choice b
Define the classes to be put in the package & declare it public
Choice c
Create the listing as java in the Subdirectory by package menu
Choice d
Execute this java file
[7] The following statements create what type of inheritance if class B and class C are
Base classes
class A extends B extends C
{
}
Choice a
Single Inheritance
Choice b
Multilevel Inheritance
Choice c
Multiple Inheritance
Choice d
Hierarchical Inheritance
[8] What keyword is used to inherit an interface
Choice a
extends
Choice b
implements
Choice c
inherits
Choice d
Contains
[9] Which String method is used to compare 2 strings considering any case
Choice a
equals
Choice b
equalto
Choice c
equalsIgnoreCase
Choice d
equalscase()
[10] Which of the following is possible using Vector class
Choice a
It is used to store objects
Choice b
It can store objects that may vary in size
Choice c
It is possible to add & delete
Choice d
All of Three
[11] In method declaration statements, which of the following is optional
Choice a
Method name
Choice b
Return type, Parameter list and body of method
Choice c
Parameter list
Choice d
Choice b
lines 6
Choice c
lines 7
Choice d
lines 5,6,7
[15] Which of the following portion specified in the for loop is compulsary
Choice a
initialization
Choice b
test condition
Choice c
increment
Choice d
All of the above
[16] Consider the following program code. state the output from it
class ifif
{
public static void main(String args[])
{
int x=3, y=1,z=5;
if(x>y)
{
if (z<=y)
{
System.out.println(y is greater than z);
}
else
{
System.out.println(z is greater than y);
}
System.out.println(x is greater than y);
}
else
{
if(y>z)
{
Three
[18] Which of the following is True with respect to branching statements if & switch
Choice a
every if statement can be written using switch
Choice b
every switch statement must have a default case
Choice c
every case must end with a break statement
Choice d
every case label follows with a(:) colon
[19] 3. What is the result if the code of statements are executed
int result = (2*(5-8)*(5-5)+10)*2;
Choice a
8
Choice b
20
Choice c
14
Choice d
0
.
[21] What is the value of the expression a<b||b<a if a is 2 and b is 1
Choice a
1
Choice b
2
Choice c
0
Choice d
TRUE
class cmdline
{
public static void main(String args[])
{
for(int i=1;i<args.length;i++)
{
System.out.print(args[i]);
if(i!=args.length)
System.out.print( );
}
System.out.println();
}
}
Choice a
Java
Choice b
Java is
Choice c
is wonderful
Choice d
cmdline Java is wonderful
[26] Which of the following is a Java keyword
Choice a
String
Choice b
super
Choice c
Mod
Choice d
Exception
[27] Which of the following is NOT a Java keyword
Choice a
throws
Choice b
try
Choice c
while
Choice d
Exception
[28] Which of the following feature of C++ is NOT supported by Java and is therefore
implemented using interfaces
Choice a
Nested Classes
Choice b
Inner Classes
Choice c
Polymorphism
Choice d
Multiple Inheritance
[29] Java is Platform-independent, What statement explain this feature
Choice a
Java programs can be easily moved from one computer system to another
Choice b
Java systems verify memory access and virus
Choice c
Java can be used to create applications on the networks
Choice d
It provides many safeguards to ensure reliable code
[30] In OOP approach programs are divided into
Choice a
Objects
Choice b
Methods
Choice c
Functions
Choice d
Procedures
[31] OOP treats what as a critical element in program development and does not allow it
to flow freely around the system.
Choice a
Procedures
Choice b
Action
Choice c
Data
Choice d
Method
[32]
Choi
ce a
Variable length
Choi
ce b
Variable len
Choi
ce c
Methods length
running
newborn
dead
blocked
Choi
ce d
Method len
[34] What is wrong in the following code
abstract class print
{
abstract show();
}
class display extends print
{
}
Choi
ce a
Nothing is wrong
Choi
ce b
Choi
ce c
Choi
ce d
Choi
ce a
private
Choi
ce b
protected
Choi
ce c
public
Choi
ce d
[36] What line numbers will cause an error when you compile this code
1 class iftest
2 {
3 public static void main(String args[])
4 {
5 int i=2;
6 if(i=2) {
7 System.out.println(Correct); }
8 else
9 System.out.println(Incorrect); }
10 }
11 }
5,9,1
0
Choice a
6,9
Choice b
Choice c
9,10
Choice d
[36] What is a value of the expression 5%3
Choice a
Choice b
Choice c
Choice d
2
1
0
3
Cho
ice b
Cho
ice c
Choice d
Converting
Cho
ice b
Changing
Cho
ice c
Defining
Cho
ice d
Casting
Cho
ice a
Cho
ice b
Cho
ice c
Cho
ice d
s can
be
Java hoi
supports
functions
written in other languages
given
such ce
as C and
C++
only at
a
Java uses less amount of memory in environment
the
Choice d
beginnin
g of
[42] Which of the following is NOT
Program
one of the web browsers
Choice c
Choice a C
hoi
Choice b ce
b
Choice c
Package
statement
should be
before
class
definition
Coldjava
Netscape Navigator
Internet Explorer
Import
C
Hotjava
Choice d hoi statement
should
be
ce
[43] In OOP process bycwhichbefore
objects of one class acquire the
class
properties of objects of another class is
definition
Inheritance
Choice a
Interface
C
hoi statement
Polymorphism
Choiceceb
should be
before
d
class
Encapsulation
Choice c
definition
Choice d
Abstraction
[44] In, Java Exception handling code what could be done in the finally block
Choice a
It is used to write initialization code
Choice b
It can be used to perform house-keeping operations
Choice c
It can be used to catch all exceptions
Choice d
It can be used to ignore all exceptions
[45] In Java, what is a condition that is caused by a run-time error in the program
Choice a
validity
Choice b
exception
Choice c
error
Choice d
Action
[46] In Multithreaded programming, the process of assigning time to thread is known as
Choice a
timing
Choice b
processing
Choice c
time-slicing
Choice d
Assigning
[47] What classes does the Java system package java.util contain
Choice a
Inheritance
Choic
eb
Method Overriding
Choic
ec
Method Overloading
Choic
ed
Final Method
[52] Which of the following visibility modifiers allows widest visibility and is accesible
everywhere
Choice a
private
Choice b
Protected
Choice c
Public
Choice d
Friendly
[53] What is valid for abstract classes and abstract methods
Choice a
We cannot use abstract classes to instantiate objects.
Choice b
abstract methods of an abstract class must be defined in its subclass.
Choice c
Constructers cannot be declared abstract
Choice d
All of the above
[54] What will be the output of the following code segment
int r=20;
while(r>0)
{
r=r-10;
if(r>0)
continue;
System.out.print("r is "+r);
}
Choice a
r is 10
Choice b
r is 0
Choice c
r is 20
Choice d
r is 20 r is 10
[55] Which of the following looping constructs body, will execute at least once even if
the condition is false.
Choice a
for
Choice b
do
Choice c
while
Choice d
none of the above.
if statement
switch statement
conditional operator statement
for construct statement
}
}
Choice a
3
Choice b
4
Choice c
10
Choice d
15
[59] Which of the following operators have lowest precedence
Choice a
unary operators
Choice b
binary operators
Choice c
bitwise operators
Choice d
logical operators
[60] Which of the following are Integer types in Java
Choice a
Byte
Choice b
Long
Choice c
Short
Choice d
All of the options 1,2,3
[61] Which of the following is NOT one of the valid escape sequence available for use in
Java
Choice a
\b
Choice b
\n
Choice c
\m
Choice d
\t
[62] Which of the following type of Programs can be developed in Java
Choice a
Standalone applications
Choice b
Web applets
Choice c
Both Option1and Option 2
Choice d
Neither Option1and Option 2
[63] JDK stands for
Choice a
Java Display Kit
Choice b
Java Direct Kit
Choice c
Java Debugger Kit
Choice d
Java Development Kit
[64] Dynamic binding is associated with
Choice a
Polymorphism
Choice b
Inheritance
Choice c
Both Option1 and Option2
Choice d
Neither Option1 and Option2
[65] In OOP, the concept of Polymorphism is
Choice a
Reusability
Choice b
Ability to take more than one form
Choice c
Sharing of data
Choice d
Hiding of data
[66] In Java when a compile-time error occurs, then which file is NOT created
Choice a
source
Choice b
.java
Choice c
.class
Choice d
.exe
[67] Which of the following is a run-time error
Choice a
Missing semicolons
Choice b
Dividing an integer by zero
Choice c
Use of undeclared variables
Choice d
Missing of brackets
[68] In Multithreaded programming, what is the constant numeric value used for setting
lowest priority for Threads
Choice a
1
Choice b
5
Choice c
4
Choice d
10
[69] What does the following import statement actually mean import java.awt.*;
Choice a
import awt class from the java package
Choice b
Import all variables from awt class
Choice c
Import all the classes from the awt package contained in the java package
Choice d
Import all the classes from the java package
[70] Java does not support Multiple Inheritance. What is an alternative approach provided
to implement this
Choice a
Packages
Choice b
Interfaces
Choice c
Collections
Choice d
Wrapper classes
[71] The method insert() is a method used with
Choice a
Arrays
Choice b
Strings
Choice c
StringBuffers
Choice d
Vectors
[72] What is the error in the following class definition
abstract class sample
{
abstract calc(int a) { }
}
Choice a
class header is not defined properly
Choice b
constructor is not defined
Choice c
method calc is not defined properly
Choice d
No error
[73] What is valid for static methods
Choice a
They can only call other static methods.
Choice b
Choice a
casting
Choice b
Promotion
Choice c
narrowing
Choice d
implicit
[77] Which of the following is essential part of a Java Program
Choice a
Packet statement
Choice b
Import statement
Choice c
Class definitions
Choice d
Main method class
[78] Which of the following is NOT a valid documentation comment used in Java
Choice a
//
Choice b
\\
Choice c
/* */
Choice d
/** */
[79] What was Java originally called as
Choice a
Object C
Choice b
Object Basic
Choice c
Oak
Choice d
Pascal
[80] Which of the following feature in C is NOT included in Java
Choice a
Break statement
Choice b
Continue statement
Choice c
Pointer type
Choice d
Primitive data types
[81] In Java, the task of handling the run-time errors and continue
executing the remaining progam is known as
Choice
a
hitting
Choice
b
throwing
Choice
c
catching
Choice
d
exception handling
pre()
Choice
b
dead()
Choice
c
stop()
Choice
d
pause()
[83] What classes does the Java system package java.awt contain
Choice
a
Choice
b
Choice
c
Choice
d
Choi
ce b
Choi
ce c
Choi
ce d
Choi
ce b
Choi
ce c
Choi
ce d
Choic
ea
r is 0
Choic
eb
r is 10
Choic
ec
r is 100
Choic
ed
r is -10
[87] What is the value of ans if the code of statements are executed
int i = 42+45-48-5;
int j = 5+5-8+2;
int ans = i%j;
2
Choice a
Choice b
Choice c
3
4
Choice d
1
2
Choice b
Choice c
Choice d
Choice
b
Choice
c
1.6
Choice
d
1.67
12
16
64
Choice b
Choice c
Choice d
a=b=c=0;
a='a'
0=b;
c=72.25
Any name
Choic
eb
Choic
ec
Choic
ed
Choic
eb
Choic
ec
Choic
ed
[93] Java is Extensible Language, What Statement best explains this feature
Choi
ce a
Choi
ce b
Choi
ce c
Choi
ce d
[94] What are user define data types and behave like built-in types of a
programming language.
Choice
a
Objects
Choice
b
Methods
Choice
c
Templates
Choice
d
Classes
Insulation
Choice
b
Linking
Choice
c
Reusability
Choice
d
Sharing
Methods
Choice b
Variables
Choice c
classes
Choice d
Both 1 & 2
[98] What value is returned by the compareTo() String method if the 2
strings compared are equal
Choic
ea
Choic
eb
Choic
ec
TRUE
Choic
ed
-1
[99] What will be displayed as output if S1 contains word "Java" with method
S1.indexOf('a')
Choice a
4
Choice b
2
Choice c
Choice d
3
[100] The concept of inheritance is implemented in Java by
Choice a
creating more than one class
Choice b
extending two or more classes
Choice c
extending one class and implementing one or more interfaces
Choice d
importing classes from packages
[101] What line numbers will cause an error when you compile this code
1 class chknum
2 {
3 public static void main(String args[])
4 {
5 int n=3;
6 switch(n);
7{
8 case 0 : System.out.print(No is 0);
9 case 1 : System.out.print(No is 1);
10 case 2 : System.out.print(No is 2);
11 case 3 : System.out.print(No is 3);
12 case 3 : System.out.print(Other Number);break;
13 } } }
Choice a
Lines 3,7,8,9,10,11
Choice b
Lines 6,8,9,10,11,12
Choice c
Lines 7,10,11
Choice d
Lines 11,12
[102] Which of the following statements do not fall in selection statement category
Choice a
if statement
Choice b
switch statement
Choice c
conditional operator statement
Choice d
for construct statement
[103] What is the output of the following program code
class check
{
public static void main(String args[])
{
boolean b=true;
System.out.println("False");
if(!b) return;
System.out.println("True");
return;
}
}
Choic
ea
True
Choic
eb
False
Choic
ec
False True
Choic
ed
Error
[104] What will be the value of b if a=2 and given the expression b=a++;
Choice a
0
Choice b
1
Choice c
2
Choice d
3
[105] What type of value will the expression (a%b) return where, a=10 and b=7.
Choice a
7
Choice b
1
Choice c
int
Choice d
float
[106] Which of the following is valid rule to create Java Identifier names
Choice a
It can contain digits, alphabets, dollar symbol and underscore
Choice b
It cannot start with a underscore
Choice c
It cannot contain uppercase letter
Choice d
It can start with a digit
[107] Which of the following is NOT one of the jump statements not available in Java
Choice a
goto
Choice b
break
Choice c
continue
Choice d
Return
[108] Which of the following C++ feature is NOT included in Java
Choice a
Multilevel inheritance
Choice b
Inner classes
Choice c
Multithreading
Choice d
Operator overloading
[109] What does message passing involve in OOP
Choice a
It involves specifying name of the object
Choice b
It involves name of the method
Choice c
It involves the information to be sent
Choice d
All of the options 1,2,3
[110] What is valid statement to import only the class color from the awt package
contained in the java package
Choice a
Choice b
Choice c
Choice d
[111]
awt.java.*;
awt.java.color;
java.awt.color;
java.awt.*;
Choic
ea
Annotations
Choic
eb
Vectors
Choic
ec
Enumerated types
Choic
ed
Object types
choice d
extends
implements
inherits
contains
[113] Which of the following form of Inheritance has one super class and many
subclasses.
Choice a
Choice b
Choice c
Choice d
Single Inheritance
Multilevel Inheritance
Hierarchical Inheritance
Multiple Inheritance
No output
Choice a
It is a vowel
Choice b
It is a consonant
Choice c
It is a vowel
It is a vowel
Choice d
[115] What is the value of Math.rint(1.999)
Choice a
Choice b
Choice c
1.9
Choice d
x
1
a
;
Choi
ce b
Choi
ce c
Choi
ce d
Choice
b
Choice
c
Choice
d
[120]
Choic
ea
Choic
eb
Choic
ec
Choic
ed
1
-1
Choice c
11
Choice d
Choice a
68
Choice b
146
Choice c
134
Choice d
Choice a
Choice b
Choice c
Choice d
[124] Which of the following String methods is used to give the nth
character of the string
Choice a
Choice b
Choice c
Choice d
substring
replace
charAt(n)
indexOf (n)
Choice a
Choice b
Choice c
Choice d
[126
]
Choice a
Choice b
Choice c
Choice d
[127]
Object
Throwable
Thread
Throw
[128 In Java, which Exception type is caused by general I/O failures such as unable to
]
read from a file
Choice a
Choice b
Choice c
InvalidAccessException
InputOutputException
InvalidFileException
Choice d
IOException