Java Programming OOPs
Questions 291 to 300
291.
|
String
s1 = “Hello”;
String
s2 = “Hello”;
System.out.println(s1
+ “equals” + s2 + “->” + s1.equals(s2));
What is the output of the following code?
|
||||||||||
292.
|
Given
below is the syntax of the method declaration in java.
Syntax: modifier returnType
MethodName (parameter List) {
statement(s);
}
Which defines the Signature of the method?
|
||||||||||
293.
|
What modifier is to be used If you
wish to declare that you want to no
longer allow subclasses to override your variables or methods?
|
||||||||||
294.
|
Which
access specifier is used for describing Applet Class?
|
||||||||||
295.
|
The following program takes any
number of numeric arguments & returns the sum & the average of those
arguments. When this program run, is it throws an error? Find which line
number is to be modified to give the correct output?
Line
1)class SumAverage {
Line
2)public static void main(String args[]) {
Line
3)int sum = 0;
Line
4)for (int I = 0; i<args.length; i++) {
Line
5)Sum += args[i];
}
Line
6)System.out.println(“Sum is;” + sum);
Line
7)System.out.println(“Average is:” +
Line
8)(float) sum / args.length);
}
}
|
||||||||||
296.
|
Select
the exception class from among the following which is part of the java.lang package.
|
||||||||||
297.
|
Consider
the following variable declarations.
int
a, b; String str;
Assume
that at some point of the program, the variables a and b contain the values 5
and 7.
Select from among the following the correct option
which assign the variable str with the value “The sum of 5 + 7 = 12”?
|
||||||||||
298.
|
Select
from among the following character escape code which is not available
in Java.
|
||||||||||
299.
|
Consider
the following program written in Java.
class
Selection{
public static void main(String args[]){ int
x=7; if(x==2); //? Note the semicolon
System.out.println("Number
seven");
System.out.println("Not seven");
} }
What would the output of the program be?
|
||||||||||
300.
|
AWT
stands for
|
Answers
291.
|
Answer : (d)
Reason: If we use the equals method
in String It will return true if the single parameter is
made up of the same characters as the object you call equals on.
|
292.
|
Answer : (d)
Reason: D is the right choice for method declaration.
|
293.
|
Answer : (c)
Reason: Final modifier is to be used If you wish to declare that you
want to no longer allow subclasses to
override your variables or methods?.
|
294.
|
Answer : (b)
Reason: All applets must be declared public because the Applet class is
a public class.
|
295.
|
Answer : (c)
Reason: SumAverage.java.6: Incompatible type for +=.
Can’t convert
java.lang.String
to int.
Sum +=
args[i];
You have to
convert them from strings to integers using a class method for the Integer
class called parseInt.
Sum += Integer.parseInt(args[i]);
|
296.
|
Answer : (d)
Reason: Remaining all are contradictory to the given statement.
|
297.
|
Answer : (c)
Reason: C is the right choice remaining all are not syntactically correct
|
298.
|
Answer : (c)
Reason: \a is not the escape sequence character when compared to other.
|
299.
|
Answer : (a)
Reason: A is the right choice .
|
300.
|
Answer : (c)
Reason: AWT stands abstract Windowing Tool Kit.
|
AWT stands for Abstract Window Toolkit
ReplyDeleteNot windowing
Java Codings with examples
ReplyDeleteAbsolutely delighted to read this post.Thank u very much
ReplyDeleteI need articles on data mining if possible
ReplyDeleteNice and very helpful C programming article...
ReplyDeleteLearn C programming with lot of examples......
Loops in C examples
C pattern programming examples
C Arrays examples
if-else in C with examples
Strings in C with examples
amazing writeup. keep posting java classes in pune
ReplyDeletegreat post, impressive , these java questions helped me a lot to prepared for my upcoming interviews and i have added these to my previous interviews questions those really helped me to crack interviews that provided by the best IT training institute java course in pune , thanks for this valuable post
ReplyDelete