Tag: technology

Questions Related to technology

  1. void method1 { /* ... */ }

  2. void method2() { /* ... */ }

  3. void method3(void) { /* ... */ }

  4. method4() { /* ... */ }


Correct Option: B
  1. abstract class Link { }

  2. native class Link { }

  3. final class Link { }

  4. abstract final class Link { }


Correct Option: C
  1. switch expression of type int and case label value of type char

  2. switch expression of type float and case label value of type int

  3. switch expression of type byte and case label value of type float

  4. switch expression of type char and case label value of type long


Correct Option: A
Explanation:

To answer this question, the user needs to have an understanding of the Java switch statement syntax and the types of expressions and case labels that are allowed within it.

A switch statement allows a program to evaluate an expression and then execute one of several possible blocks of code, depending on the value of the expression. The expression and case labels must be of a compatible type. Compatible types are those that can be implicitly converted to each other without loss of information.

Now, let's go through each option and explain why it is right or wrong:

A. switch expression of type int and case label value of type char: This option is legal. The char type can be implicitly promoted to int, which means that a char can be used as a case label with an int expression.

B. switch expression of type float and case label value of type int: This option is illegal. The int type can't be implicitly converted to float, which means that an int cannot be used as a case label with a float expression.

C. switch expression of type byte and case label value of type float: This option is illegal. The float type can't be implicitly converted to byte, which means that a float cannot be used as a case label with a byte expression.

D. switch expression of type char and case label value of type long: This option is illegal. The long type can't be implicitly converted to char, which means that a long cannot be used as a case label with a char expression.

Therefore, the correct answer is:

The Answer is: A. switch expression of type int and case label value of type char

  1. {{}} is a valid statement block

  2. { continue; } is a valid statement block

  3. block: { break block; } is a valid statement block

  4. block: { continue block; } is a valid statement block


Correct Option: A,C
  1. Compilation error.

  2. Runtime error

  3. Compiles Fine

  4. Depends on the code where you use


Correct Option: A
  1. Inheritance defines a has-a relationship between a superclass and its subclasses

  2. Every Java object has a public method named equals

  3. A class can extend any number of other classes

  4. A non-final class can be extended by any number of classes


Correct Option: B,D
  1. Attributes and Fields

  2. Fields and Records

  3. Records and Fields

  4. Fields and Attributes


Correct Option: C
  1. Having no programs open in desktop

  2. having no paper pieces with information on desk

  3. having no icons except recycle bin on desktop

  4. none of the above


Correct Option: A