Tag: java

Questions Related to java

  1. double D = 45456.444;

  2. long L = 45784;

  3. int I = L;

  4. int J = (int) D;


Correct Option: C
  1. After object B is notified, or after two seconds

  2. After the lock on B is released, or after two seconds

  3. Two seconds after object B is notified

  4. Two seconds after lock B is released.


Correct Option: A
  1. It must be marked final

  2. It can be marked abstract

  3. It can be marked public

  4. It can be marked static


Correct Option: B
  1. It can extend exactly one class and implement exactly one interface

  2. It can extend exactly one class and can implement multiple interfaces

  3. It can extend exactly one class or implement exactly one interface

  4. It can implement multiple interfaces regardless of whether it also extends a class

  5. It can implement multiple interfaces if it does not extend a class


Correct Option: C
  1. The java command can access classes from more than one package, from a single JAR file.

  2. JAR files can be used with the java command but not with the javac command.

  3. In order for JAR files to be used by java, they MUST be placed in the /jre/lib/ext sub-directory within the J2SE directory tree.

  4. When a part of a directory tree that includes subdirectories with files is put into a JAR file, all of the files are saved in the JAR file, but the subdirectory structure is lost.


Correct Option: A

Which of the following statement is true?

  1. X extends Y is correct if and only if X is a class and Y is an interface

  2. X extends Y is correct if and only if X is an interface and Y is a class

  3. X extends Y is correct if X and Y are either both classes or both interfaces

  4. X extends Y is correct for all combinations of X and Y being classes and/or interfaces.


Correct Option: C

AI Explanation

To answer this question, you need to understand the concept of inheritance in object-oriented programming.

Option A) X extends Y is correct if and only if X is a class and Y is an interface - This option is incorrect because in Java, a class can extend another class or implement an interface. It is not limited to only extending classes and implementing interfaces.

Option B) X extends Y is correct if and only if X is an interface and Y is a class - This option is incorrect because in Java, a class can extend another class or implement an interface. It is not limited to only extending interfaces and implementing classes.

Option C) X extends Y is correct if X and Y are either both classes or both interfaces - This option is correct. In Java, a class can extend another class and implement multiple interfaces. Similarly, an interface can extend multiple interfaces. So, X extends Y is correct if both X and Y are either both classes or both interfaces.

Option D) X extends Y is correct for all combinations of X and Y being classes and/or interfaces - This option is incorrect because, as explained above, extending a class and implementing an interface are two different concepts in Java. The correct statement is that X extends Y is correct if both X and Y are either both classes or both interfaces.

The correct answer is Option C.

  1. The attributes of the class are all private

  2. The class refers to a small number of other objects

  3. The object contains only a small number of variables

  4. The object is referred to using an anonymous variable, not directly

  5. The reference variable is declared for an interface type, not a class. The interface provides a small number of methods


Correct Option: E
  1. must be created via a Java IDE.

  2. can run on different machines, but only with the same Operating System.

  3. are typically based on Servlets, JSPs and Enterprise Java Beans.

  4. need no runtime environment.


Correct Option: C