Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
] 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
[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
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.*;
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
extends
Choice b
implements
Choice c
inherits
Choice d
Contains
[22]
Choi
ce a
Annotations
Choi
ce b
Vectors
Choi
ce c
Enumerated
types
Choi
ce d
Object types
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
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
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
r is 10
Choice b
r is 0
Choice c
r is 20
Choice d
r is 20 r is 10
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
[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
}
}
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
Choi
ce b
Choi
ce c
Choi
ce d
[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
Choice b
Choice c
Choice d
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
Standalone applications
Choice b
Web applets
Choice c
Choice d
Choice
b
Choice c
Choice
d
Choice b
Choice c
Choice d
Coldjava
Choice b
Netscape Navigator
Choice c
Internet Explorer
Choice d
Hotjava
Ans: 4.d
Choice a
Polymorphism
Choice b
Inheritance
Choice c
Choice d