Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Nive8989
N
Nive8989
Community Contributor
Quizzes Created: 1 | Total Attempts: 229
| Attempts: 229 | Questions: 30
Please wait...
Question 1 / 30
0 %
0/100
Score 0/100
1. Both TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE types                 ResultSets will make changes visible if they are closed and then reopened.                 State True or False.

Explanation

Both TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE ResultSets will make changes visible if they are closed and then reopened. This means that any changes made to the underlying data source will be reflected in the ResultSet when it is closed and then reopened. Therefore, the statement "True" is correct.

Submit
Please wait...
About This Quiz
Eclipse Java - Quiz

This Eclipse JAVA quiz assesses knowledge in Java programming, focusing on thread handling, operations, and concurrency. It tests understanding of thread behavior, output predictions, and Java's fundamental concepts, enhancing learners' debugging and Java development skills.

Tell us your name to personalize your report, certificate & get on the leaderboard!
2. Consider the following code: public class TestOne {    public static void main(String args[])      {        byte x = 3;         byte y = 5;         System.out.print((y%x) + ", "); System.out.println(y == ((y/x) *x +(y%x))); } } Which of the following gives the valid output for above?

Explanation

The code first calculates the remainder of y divided by x using the modulus operator (%), which is 2. Then it checks if y is equal to the result of ((y/x) * x + (y%x)), which simplifies to ((5/3) * 3 + 2), which further simplifies to (1 * 3 + 2), which equals 5. Since y is indeed equal to 5, the expression evaluates to true. Therefore, the output will be "2, true".

Submit
3. Consider the following code snippet:                class TestString3 {                   public static void main(String args[]) {                     String s1 = "Hello";                     StringBuffer sb = new StringBuffer(s1);                         sb.reverse();                         s1.concat(sb.toString());                         System.out.println(s1 + sb + s1.length() + sb.length());                  } }            What will be the output of the above code snippet?

Explanation

The output of the code snippet will be "HelloolleH55". This is because the code first creates a StringBuffer object "sb" and reverses it using the reverse() method. Then, it concatenates the reversed "sb" with the original string "s1" using the concat() method. However, the result of the concatenation is not stored in any variable. Finally, it prints the concatenation of "s1" and "sb", followed by the lengths of both strings. Since "s1" is still "Hello" and "sb" is reversed to "olleH", the output is "HelloolleH55".

Submit
4. Dd3)6)  Consider the following code:   public class Code17  {      public static void main(String args[]) {      new Code17();       }      { System.out.print("Planet "); }      { System.out.print("Welcome "); }      }      Which of the following will be the valid output for the above code?

Explanation

The valid output for the given code will be "Planet Welcome". This is because the code is creating an instance of the class Code17 in the main method. Before the main method, there are two initialization blocks that print "Planet" and "Welcome" respectively. When the instance is created, these initialization blocks are executed in the order they appear, resulting in the output "Planet Welcome".

Submit
5. What can cause a Thread to become non-runnable?

Explanation

Calling the wait method on an object can cause a Thread to become non-runnable. The wait method is used to make a thread wait until another thread notifies it to resume. When a thread calls the wait method, it releases the lock on the object it is synchronized on and enters a waiting state. This means that the thread cannot continue its execution until it is notified by another thread. Therefore, calling the wait method on an object can cause a thread to become non-runnable.

Submit
6. Which of the following lines will compile without warning or error?

Explanation

The line "int i=10;" will compile without warning or error because it is assigning a valid integer value (10) to the integer variable "i".

Submit
7. What of the following is the default Scroll type for a ResultSet object?

Explanation

The default Scroll type for a ResultSet object is ResultSet.TYPE_FORWARD_ONLY. This means that the ResultSet can only be traversed in a forward direction and does not support scrolling or moving backwards.

Submit
8. Consider the following code segment:  public class ExampleTwo {    public static void main(String args[]) {    int z = 8;    z += --z;    System.out.println("Value of z : " + z);  }  }           Which of the following gives the valid output for above?

Explanation

The code segment starts with initializing the variable z to 8. Then, the expression "z += --z" is evaluated. The "--z" decrements the value of z by 1, resulting in z becoming 7. The "+=" operator adds the value of z (7) to the current value of z (7), resulting in z becoming 14. Finally, the value of z (14) is printed as part of the output statement "Value of z: 14". Therefore, the valid output for the code segment is "Value of z: 14".

Submit
9. Consider the following code snippet:  String a = "abc";  For the expression a="\""+a+"\""        What will be the output of the above code snippet?

Explanation

The code snippet concatenates the string "abc" with double quotes at the beginning and end. The backslash before each double quote is an escape character that allows the double quote to be included in the string. Therefore, the output of the code snippet will be "abc".

Submit
10. Consider the following program:                 public class D extends Thread { public void run() {                   System.out.println("Before start method");                    this.stop();                    System.out.println("After stop method");                    }                    public static void main(String[] args) {                      D a = new D(); a.start();                      } }        What will be the output of the above program?

Explanation

The correct answer is 'Before start method' only. This is because the stop() method is called immediately after the start() method, which causes the thread to stop before it even starts executing the run() method. Therefore, the only output that will be printed is 'Before start method'.

Submit
11. Which of the following flow control features does Java support? (Choose 2)

Explanation

Java supports the flow control features of labeled continue and labeled break. Labeled continue allows the program to skip the current iteration of a labeled loop and move to the next iteration. Labeled break allows the program to exit a labeled loop or switch statement. These features provide flexibility and control over the flow of execution in Java programs.

Submit
12. Which of the following are characteristics of Annotations?(Choose 2)

Explanation

Annotations are not part of a program because they are metadata that provide additional information about the program but do not affect the program's execution. They can be used to add descriptive data or instructions to the program. Annotations are data about the program because they can be used to store information about the program's structure, behavior, or usage. This data can be accessed at runtime using reflection or used by other tools for code analysis or generation.

Submit
13. Consider the following code:                 class Alpha {                    protected Beta b;                     }                 class Gamma extends Alpha { }                 class Beta { }          Which of the following statement is True?

Explanation

not-available-via-ai

Submit
14. Consider the following code:   public class SwitchCase {    public static void main(String args[]) {     int x = 10; switch(x) {     case 10: System.out.println("10");     case 10: System.out.println("10");     case 20: System.out.println("20");     default: System.out.println("30");  } } }       Which of the following will be the output for the above program?

Explanation

The code will result in a compilation error because there are duplicate case labels in the switch statement. The case label "10" appears twice, which is not allowed in Java. Each case label in a switch statement must be unique.

Submit
15. A)Entries are not organised in key/value pairs.       b)Duplicate entries are rejected        Which interface of the java.util package offers the above specified behaviour?

Explanation

The correct answer is Set. The Set interface in the java.util package does not organize entries in key/value pairs and it rejects duplicate entries. This means that each element in a Set must be unique and there is no specific order maintained for the elements.

Submit
16. Which of these belong to the set of Java keywords?

Explanation

None of the listed options belong to the set of Java keywords. Java keywords are predefined reserved words that have specific meanings and cannot be used as identifiers or variable names. The given options "statement", "validate", "assertion", and "exception" are not Java keywords.

Submit
17. Consider the following line of Code:         int x[]=new int[25];        After execution ,which of the following statement/ statements are true?

Explanation

The given line of code initializes an array of integers called "x" with a size of 25. In Java, when an array of integers is created, all elements are automatically initialized to their default value, which is 0 for integers. Therefore, x[24] is 0. Additionally, the length property of an array in Java returns the number of elements in the array, so x.length is 25. The other statements are incorrect.

Submit
18. Consider the following code snippet:  class Sample{  public static void main(String[] args){                    for(int i=0;i<5;i++){  switch(i)     case 0: System.out.println("v");break;     case 0: System.out.println("w");     case 0: System.out.println("x");break;     case 0: System.out.println("y");                       case 0: System.out.println("z");break;     case 0: System.out.println("d");                  }}}} What is the result of attempting to compile and run the program?

Explanation

The correct answer is "Prints: v w x x y z z". The code snippet contains a switch statement with multiple cases labeled as 0. Since all the cases have the same label, the code execution will fall through each case until it reaches a break statement. Therefore, when the variable i is 0, the code will print "v", "w", "x", and "z" because there are no break statements after these cases. As a result, the program will print "v w x x y z z".

Submit
19. Which of the following are true about inheritance?(Choose 3)

Explanation

Inheritance allows for the creation of a hierarchy where a superclass can also act as a subclass, meaning that it can inherit properties and methods from a higher-level class. Similarly, a subclass can also act as a superclass, meaning that it can have its own subclasses that inherit from it. This enables the sharing of data and methods among multiple classes, contradicting the statement that inheritance does not allow sharing. Additionally, inheritance allows for the addition of new features and functionality to an existing class without modifying the existing class, making it a powerful tool for extending and enhancing code.

Submit
20. Consider the following code:  class A {    public A getMe() {     return this;                    }  }  class B extends A {   public static void main(String args[]) {    A a = new B() {  public A getMe() {                     return this;  } };  System.out.println(a.getClass().getSuperclass().getName());   } }           Which of the following will be the output of the above code snippet?

Explanation

The output of the code snippet will be "Object". This is because the code creates an anonymous class that extends class B, and overrides the getMe() method. When the getMe() method is called on the object "a", it returns the reference to the anonymous class object. However, when we use getClass().getSuperclass().getName(), it returns the superclass of the object, which is class A. Finally, getName() returns the name of the class, which is "Object" for the superclass.

Submit
21. Which of the following methods are defined in Object class? (Choose 3)

Explanation

The methods equals(Object), hashCode(), and toString() are defined in the Object class. The equals(Object) method is used to compare two objects for equality, the hashCode() method returns the hash code value for an object, and the toString() method returns a string representation of an object. These three methods are fundamental methods in Java and are inherited by all classes in the Java language.

Submit
22. Consider the following code snippet:                 import java.io.*;                  public class IOCode1 {                      public static void main(String args[]) throws IOException {                            BufferedReader br1 = new BufferedReader( new InputStreamReader(System.in));                             BufferedWriter br2 = new BufferedWriter( new OutputStreamWriter(System.out));                             String line = null;                            while( (line = br1.readLine()) != null )                         {                             br2.write(line);                              br2.flush();                           }                                br1.close();                                 br2.close();                  } }                   What will be the output for the above code snippet?

Explanation

The code snippet uses BufferedReader to read input from the keyboard line by line using the readLine() method. It then uses BufferedWriter to write the input to the console using the write() method. The code also flushes the output using the flush() method. Therefore, the code reads the text from the keyboard line by line and prints the same to the console on pressing the ENTER key at the end of every line.

Submit
23. Which of the following are the valid ways of creating wrapper type objects? (Choose 3)

Explanation

not-available-via-ai

Submit
24. Which of the statements are True?

Explanation

A constructor can be declared as private means that a class can have a private constructor, which can only be accessed within the class itself. This is often used to restrict the creation of objects of that class to specific methods or within the class itself.

A constructor can access the non-static member of a class means that a constructor can access and initialize the non-static variables or members of a class. This allows the constructor to set initial values for the variables when an object is created.

Submit
25. Which of the following statements are true?(Choose 2)

Explanation

The correct answer is that an object is a collection of properties and methods and a package is a collection of classes. In object-oriented programming, an object is an instance of a class that encapsulates data (properties) and behavior (methods). A package, on the other hand, is a way to organize and group related classes together. Therefore, it is true that a package is a collection of classes.

Submit
26. Consider the following program:   class A extends Thread {    public A(Runnable r) {}    public void run() {    System.out.print("A");    } }  class B implements Runnable {    public void run(){    System.out.print("B");    } }  class C{    public static void main(String[] args) {    new A(new B()).start();    } }  What will be the output of the above program?

Explanation

The program creates an instance of class A, passing an instance of class B as a parameter to its constructor. Class A extends Thread and overrides the run() method to print "A". Therefore, when the new A object is started, it will execute the run() method and print "A" as the output.

Submit
27. Which of the following exhibits the different ways of constructing a String object?(Choose 3)

Explanation

The correct answer choices demonstrate three different ways of constructing a String object. First, creating a String using an empty string literal: String s = new String("");. Second, constructing a String from byte arrays: String can be constructed from byte arrays. Lastly, creating a String from character arrays: String can be made from character arrays.

Submit
28. Which of the following are methods static members of the Thread class? (Choose all that apply)

Explanation

The correct answer is sleep and yield. The sleep method is a static method in the Thread class that allows a thread to pause for a specified amount of time. The yield method is also a static method in the Thread class that allows a thread to voluntarily give up its current time slice and allow other threads to execute. The start, run, and wait methods are not static methods in the Thread class.

Submit
29. Which of the following annotations are NOT defined in java.lang.annotation package? (Choose 2)

Explanation

The annotations @Deprecated, @SuppressWarnings, and @Override are not defined in the java.lang.annotation package. These annotations are part of the java.lang package, but not specifically defined in the java.lang.annotation package.

Submit
30. Consider the following scenario: You are writing a set of classes related to cooking and have created your own exception hierarchy derived from java.lang.Exception as follows: Exception     +-Bad TasteException     +-Bitter Exception     +-Sour Excpetion BadTasteException is defined as an abstract class. You have a method eatMe that may throw a BitterException or a SourException. Which of the following method declarations are acceptable to the compiler? (Choose 3)

Explanation

The compiler will accept the method declarations that correctly handle the exceptions that may be thrown by the eatMe method.
- The declaration "public void eatMe() throws BadTasteException" is acceptable because it correctly handles the exception of type BadTasteException that may be thrown by the method.
- The declaration "public void eatMe() throws RuntimeException" is acceptable because RuntimeException is an unchecked exception and does not need to be declared in the method signature.
- The declaration "public void eatMe() throws BitterException, SourException" is acceptable because it correctly handles the exceptions of type BitterException and SourException that may be thrown by the method.

Submit
View My Results

Quiz Review Timeline (Updated): Jul 12, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jul 12, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 19, 2011
    Quiz Created by
    Nive8989
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Both TYPE_SCROLL_SENSITIVE and TYPE_SCROLL_INSENSITIVE types...
Consider the following code:...
Consider the following code snippet:...
Dd3)6)  Consider the following code:...
What can cause a Thread to become non-runnable?
Which of the following lines will compile without warning or error?
What of the following is the default Scroll type for a ResultSet...
Consider the following code segment:...
Consider the following code snippet:...
Consider the following program:...
Which of the following flow control features does Java support?...
Which of the following are characteristics of Annotations?(Choose 2)
Consider the following code:...
Consider the following code:...
A)Entries are not organised in key/value pairs....
Which of these belong to the set of Java keywords?
Consider the following line of Code:...
Consider the following code snippet:...
Which of the following are true about inheritance?(Choose 3)
Consider the following code:...
Which of the following methods are defined in Object class? (Choose 3)
Consider the following code snippet:...
Which of the following are the valid ways of creating wrapper type...
Which of the statements are True?
Which of the following statements are true?(Choose 2)
Consider the following program:...
Which of the following exhibits the different ways of constructing a...
Which of the following are methods static members of the Thread class?...
Which of the following annotations are NOT defined in...
Consider the following scenario:...
Alert!

Advertisement