Sei sulla pagina 1di 9

[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 when a compile-time error occurs, then which file is NOT created
]
Choice a

source

Choice b

.java

Choice c

.class

Choice d

.exe

[28
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

[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 is valid statement to import only the class color from the awt package contained in
] the java package
Choice a

awt.java.*;

Choice b

awt.java.color;

Choice c

java.awt.color;

Choice d

java.awt.*;

[25 To create a package what is the first statement included?


]
Choice a

import java.aw+.*;

Choice b

package

Choice c

public

Choice d

class

[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 keyword is used to inherit an interface


]
Choice a

extends

Choice b

implements

Choice c

inherits

Choice d

Contains

[22]

Which of the following are


similar to the Static final
constants

Choi
ce a

Annotations

Choi
ce b

Vectors

Choi
ce c

Enumerated
types

Choi
ce d

Object types

[21 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

[20 What is wrong in the following code


] abstract class print
{
abstract show();
}
class display extends print
{
}
Choice a

Nothing is
wrong

Choice b

Method
show()
should have
a return type

Choice c

Method
show() is

not
implemente
d in class
display
Choice d

class display
does not
contain
anything

[20 What is wrong in the following code


]
abstract class print
{
abstract show();
}
class display extends print
{
}
Choice a

Nothing is
wrong

Choice b

Method
show()
should have
a return type

Choice c

Method
show() is
not
implemente
d in class
display

Choice d

class display
does not
contain
anything

[18 Which of the following form of Inheritance has one super class and many subclasses.
]
Choice a

Single Inheritance

Choice b

Multilevel Inheritance

Choice c

Hierarchical Inheritance

Multiple Inheritance

Choice d

[17] 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

[17 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

[16] Which of the following portion specified in the for loop is compulsary
Choi
ce a

initialization

Choi
ce b

test condition

Choi
ce c

increment

Choi
ce d

All of the above

[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
z is greater than y

[14 What is the result if the code of statements are executed


]
class swtest
{
public static void main(String args[])
{
char ch=i;
switch(ch)
{
case a :
case e :
case i : System.out.println(It is a vowel);
case o :
case u : System.out.println(It is a vowel);break;
default : System.out.println(It is a consonant);
}

}
}
Choice a

No output

Choice b

It is a vowel

Choice c

It is a consonant

Choice d

It is a vowel
It is a vowel

[13] Which of the following is True with respect to branching statements if &
switch
Choi
ce a

every if statement can be written


using switch

Choi
ce b

every switch statement must


have a default case

Choi
ce c

every case must end with a break


statement

Choi
ce d

every case label follows with a(:)


colon

[12] 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;
Choice a

Choice b

Choice c

34

Choice d

12

[12] 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;
Choice a

Choice b

Choice c

34

Choice d

12
[10] What is the value of Math.rint(1.999)
Choi

ce a
Choi
ce b

Choi
ce c

Choi
ce d

1.9

[9] Which of the following it NOT a valid character constant


Choice a

Choice b

Choice c

Choice d

[9] Which of the following it NOT a valid character constant


Choice a

Choice b

Choice c

Choice d

[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 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

[5] Which of the following is NOT true with respect to Java


Program Structure
Choice a

Comments can be given only at the


beginning of Program

Choice
b

Package statement should be before class


definition

Choice c

Import statement should be before class


definition

Choice
d

Interface statement should be before class


definition

[4] Java is Robust, 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

[3] Which of the following is NOT one of the web browsers


Choice a

Coldjava

Choice b

Netscape Navigator

Choice c

Internet Explorer

Choice d

Hotjava

[2] Dynamic binding is associated with

Ans: 4.d

Choice a

Polymorphism

Choice b

Inheritance

Choice c

Both Option1 and Option2

Choice d

Neither Option1 and Option2

Potrebbero piacerti anche