Given:
public class Equal {
public static void main(String[] args) {
String str1 = "Java";
String[] str2 = {"J","a","v","a"};
String str3 = "";
for (String str : str2) {
str3 = str3+str;
}
boolean b1 = (str1 == str3);
boolean b2 = (str1.equals(str3));
System.out.print(b1+", "+b2);
}
What is the result?
A.
true, false
B.
false, true
C.
true, true
D.
false, false
false, true
strict equality.
equals compare state, not identity
Which usage represents a valid way of compiling java source file with the name "Main"?
A.
javac Main.java
B.
java Main.class
C.
java Main.java
D.
javac Main
E.
java Main
javac Main.java
The compiler is invoked by the javac command. When compiling a Java
class, you must include the file name, which houses the main classes including the Java
extension. So to run Main.java file we have to use command in option A.
TO execute Java program we can use Java command but can't use it for compiling.
https://docs.oracle.com/javase/tutorial/getStarted/application/index.html
Given:
What is the result?
A.
200.0 : 100.0
B.
400.0 : 200.0
C.
400.0 : 100.0
D.
Compilation fails
400.0 : 100.0
Given:
What is the result?
A.
hEllOjAvA!
B.
Hello java!
C.
Out of limits
hEllOjAvA!
D.
Out of limits
Out of limits
hEllOjAvA!
Which statement is true?
A.
Both p and s are accessible by obj.
B.
Only s is accessible by obj.
C.
Both r and s are accessible by obj.
D.
p, r, and s are accessible by obj.
Only s is accessible by obj.
Given the code fragment:
What is the result?
A.
Found Red
Found Default
B.
Found Teal
C.
Found Red
Found Blue
Found Teal
D.
Found Red
Found Blue
Found Teal
Found Default
E. Found Default
Found Teal
Which statement is/are true?
I. Default constructor only contains "super();" call.
II. We can't use any access modifier with a constructor.
III. A constructor should not have a return type.
A.
Only I.
B.
Only II.
C.
Only I and II.
D.
Only I and III.
E.
AIL
Only I and III.
Statement I is correct as the default constructor only contains super0 call
Statement II is incorrect as we can use any access modifier with a constructor.
Statement III is correct as constructor can't have return type, even void.
So option D is correct.
httpsy/docs.oracle.com/javase/tutorial/iava/javaOO/construaors.html
Given:
public class SampleClass {
public static void main(String[] args) {
AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new
SampleClass();
sc = asc;
System.out.println("sc: " + sc.getClass());
System.out.println("asc: " + asc.getClass());
}}
class AnotherSampleClass extends SampleClass {
}
What is the result?
A.
sc: class Object
asc: class AnotherSampleClass
B.
sc: class SampleClass
asc: class AnotherSampleClass
C.
sc: class AnotherSampleClass
asc: class SampleClass
D.
sc: class AnotherSampleClass
asc: class AnotherSampleClass
sc: class AnotherSampleClass
asc: class AnotherSampleClass
Given:
A.
Option A
B.
Option B
C.
Option C
D.
Option D
E.
Option E
Option B
Option C
When an abstract class is subclassed, the subclass usually provides
implementations for all of the abstract methods in its parent class (C). However, if it does
not, then the subclass must also be declared abstract (B).
Note: An abstract class is a class that is declared abstract—it may or may not include
abstract methods. Abstract classes cannot be instantiated, but they can be subclassed
Given the code fragment
Which option represents the state of the num array after successful completion of the outer
loop?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
Option A
Given:
What is the result?
A.
Good Day!
Good Luck!
B.
Good Day!
Good Day!
C.
Good Luck!
Good Day!
D.
Good Luck!
Good Luck!
E.
Compilation fails
Compilation fails
View the exhibit.
Which change enables the code to print the following?
James age: 20
Williams age: 32
A.
Replacing line 5 with public static void main (String [] args) throws MissingInfoException,
AgeOutofRangeException {
B.
Replacing line 5 with public static void main (String [] args) throws.Exception {
C.
Enclosing line 6 and line 7 within a try block and adding:
catch(Exception e1) { //code goes here}
catch (missingInfoException e2) { //code goes here}
catch (AgeOutofRangeException e3) {//code goes here}
D.
Enclosing line 6 and line 7 within a try block and adding:
catch (missingInfoException e2) { //code goes here}
catch (AgeOutofRangeException e3) {//code goes here}
Enclosing line 6 and line 7 within a try block and adding:
catch(Exception e1) { //code goes here}
catch (missingInfoException e2) { //code goes here}
catch (AgeOutofRangeException e3) {//code goes here}
Page 4 out of 20 Pages |
Previous |