Вы находитесь на странице: 1из 11

[30] Which exception may be thrown if the given code is executed giving 2 integer 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
[29] 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
[28] 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
[27] In Multithreaded programming, which method is used to return the threads to runnable state
from the wait state
Choice a
notify()
Choice b
resume()
Choice c
start()
Choice d
Runnable()
[26] What classes does the Java system package java.awt contain
Choice a
Classes for primitive types,Strings,Math functions, Threads and Exceptions
Choice b
Classes such as Vectors, hash tables, random numbers, date etc
Choice c
Classes for Input/Output support
Choice d
Classes for implementing graphical user interface
[24] 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
[23] What can interfaces contain?
Choice a
Methods
Choice b
Variables
Choice c
classes
Choice d
Both 1 & 2
Date 27 Jun 2012
[22] What value is returned by the compareTo() String method if the 2 strings
compared are equal
Choice
a

Choice
b

Choice
c

TRU
E

-1
Choice
d
[21] What will be displayed as output if S1 contains word "Java" with method S1.indexOf('a')
Choice a
4
Choice b
2
Choice c
1
Choice d
3
[20] 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
[19] What is valid for static methods
Choice a
They can only call other static methods.
Choice b
They can only access static data.
Choice c
They cannot refer to this or super
Choice d
All of the above
[18] An expression using operators && and || used to combine two or more relational statement
is called
Choice a
combined expression
Choice b
relational expression
Choice c
logical expression
Choice d
boolean expression
[17] What will be the output of the following code segment
int r=100;
while(true)
{
if(r<10)
break;
r=r-10;
}
System.out.print(r is +r);
Choice a
r is 0

Choice b
r is 10
Choice c
r is 100
Choice d
r is -10
[16] Which of the following is NOT one of the looping constructs available in Java
Choice a
switch
Choice b
while
Choice c
do
Choice d
for
[15] 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)
{
System.out.println(y is greater than z);
}

}
}
}
Choice a
z is greater than y
x is greater than y
Choice b
y is greater than z
x is greater than y
Choice c
x is greater than y
x is greater than z
Choice d
x is greater than y
[14] 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
[13] 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
Date 27 Jun 2012
[12] 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;
}
}
Choice
a

True

Choice
b

False

Choice
c

False
True

Error
Choice
d
[11] 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
[10] 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
[9] 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
[8] Which of the following is NOT a valid assignment statement
Choice a
a=b=c=0;
Choice b
a='a'
Choice c
0=b;
Choice d
c=72.25
[7] What will be the output of the following code, if executed with command line arguments as
follows
java cmdline Java is wonderful
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
[6] 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
[5] 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
[4] What is HotJava
Choice a
It is first program written in Java and is web browser
Choice b
It is applet to run a browser

Choice c
It is network application to run applets
Choice d
It is program that can edit applets
Return
[3] 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
[2] In OOP approach programs are divided into
Choice a
Objects
Choice b
Methods
Choice c
Functions
Choice d
Procedures
[1] 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

Вам также может понравиться