Premium

Oracle Java Programming Certification Questions and Answers (Dumps and Practice Questions)



Question : You have been given below code

public class DoBreak1 {
public static void main(String[] args) {
String[] table = { "aa", "bb", "cc", "dd" };
for (String ss : table) {
if ("bb".equals(ss)) {
continue;
}
System.out.println(ss);
if ("cc".equals(ss)) {
break;
}
}
}
}

What would be printed ?

 : You have been given below code
1. aa cc
2. aa bb cc
3. Access Mostly Uused Products by 50000+ Subscribers
4. cc

5. Compilation fails.



Correct Answer : Get Lastest Questions and Answer :
Explanation:








Question : You have been given following code

public class TestOperator {
public static void main(String[] args) {
int result = 30 - 12 / (2 * 5) + 1;
System.out.print("Result = " + result);
}
}

What is the result?


 : You have been given following code
1. Result = 2
2. Result = 3
3. Access Mostly Uused Products by 50000+ Subscribers
4. Result = 29
4. Result = 30




Correct Answer : Get Lastest Questions and Answer :





Question : Which three are bad practices?

A. Checking for ArrayIndexoutofBoundsException when iterating through an array to determine when all elements have been visited
B. Checking for Error and. If necessary, restarting the program to ensure that users are unaware problems
C. Checking for FileNotFoundException to inform a user that a filename entered is not valid
D. Checking for ArrayIndexoutofBoundsException and ensuring that the program can recover if one occur
E. Checking for an IOException and ensuring that the program can recover if one occurs

 : Which three are bad practices?
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,B,D
5. B,C,D



Correct Answer : Get Lastest Questions and Answer :
Explanation:





Related Questions


Question : Which three statements are true about the structure of a Java class?
A. A class can have only one private constructor.
B. A method can have the same name as a field.
C. A class can have overloaded static methods.
D. A public class must have a main method.
E. The methods are mandatory components of a class.
F. The fields need not be initialized before use.

 : Which three statements are true about the structure of a Java class?
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. D,E,F

5. A,E,F






Question : Which two items can legally be contained within a java class declaration?
A. An import statement
B. A field declaration
C. A package declaration
D. A method declaration

 : Which two items can legally be contained within a java class declaration?
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. B,D

5. A,D






Question : Which two may precede the word 'class' in a class declaration?
A. local
B. public
C. static
D. volatile
E. synchronized

 : Which two may precede the word 'class' in a class declaration?
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. D,E

5. A,E






Question : You have been given below code. Which is a correct statement ?

ArrayList list = new ArrayList<>(1);
list.add(1001);
list.add(1002);
System.out.println(list.get(list.size()));

 : You have been given below code. Which is a correct statement ?
1. Compilation fails due to an error on line 1
2. An exception is thrown at run time due to error on line 3
3. Access Mostly Uused Products by 50000+ Subscribers
4. 1002



Question : 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.

  : Which statement is/are true?
1. Only I.
2. Only II.
3. Access Mostly Uused Products by 50000+ Subscribers
4. Only I and III.

5. ALL I, II, III






Question : You have been given following code

public class Student {
public String name = "";
public int age = 0;
public String major = "Undeclared";
public boolean fulltime = true;

public void display() {
System.out.println("Name: " + name + " Major: " + major);
}

public boolean isFullTime() {
return fulltime;
}
}


public class TestStudent {
public static void main(String[] args) {
Student bob = new Student();
bob.name = "Bob";
bob.age = 18;
bob.year = 1982;
}
}

What is the result?

 : You have been given following code
1. year is set to 1982.
2. bob.year is set to 1982
3. Access Mostly Uused Products by 50000+ Subscribers
4. A compile time error is generated.