Tag: programming languages

Questions Related to programming languages

Which of these lists contains at least one word that is not a Java keyword?

  1. abstract, default, if, private, this

  2. do, implements, protected, boolean, throw

  3. case, extends, int, short, try

  4. import, break, double, exception, throws

  5. byte, else, instanceof, return, transient

  6. None of the above


Correct Option: D

class Identifiers { int i1; // 1 int _i2; // 2 int i_3; // 3 int #i4; // 4 int $i5; // 5 int %i6; // 6 int i$7; // 7 } Compile-time errors are generated at which lines?

  1. 1

  2. 2

  3. 3

  4. 4

  5. 5

  6. 6


Correct Option: D,F
  1. Encapsulation is a form of data hiding.

  2. A tightly encapsulated class is always immutable.

  3. Encapsulation is always used to make programs run faster.

  4. Encapsulation helps to protect data from corruption.

  5. Encapsulation allows for changes to the internal design of a class while the public interface remains unchanged.


Correct Option: A,D,E
  1. A top-level class can not be called "tightly encapsulated" unless it is declared private.

  2. Encapsulation enhances the maintainability of the code.

  3. A tightly encapsulated class allows fast public access to member fields.

  4. A tightly encapsulated class allows access to data only through accessor and mutator methods.

  5. Encapsulation usually reduces the size of the code.

  6. A tightly encapsulated class might have mutator methods that validate data before it is loaded into the internal data model.


Correct Option: B,D,F
  1. The class is declared final.

  2. All local variables are declared private.

  3. All method parameters are declared final.

  4. No method returns a reference to any object that is referenced by an internal data member.

  5. None of the above


Correct Option: E

class GFC506 {private String name;} class GFC507 extends GFC506 { String name; public void setName(String name) {this.name = name;} public String getName() {return name;} } class GFC508 extends GFC506 { private String name; public GFC508(String name) {setName(name);} public void setName(String name) {this.name = name;} public String getName() {return name;} } Which class is not tightly encapsulated?

  1. GFC506

  2. GFC507

  3. GFC508

  4. None of the above


Correct Option: B
  1. -disableassertions

  2. -disableAssertions

  3. -assertionsDisable

  4. -assertionsOn

  5. -assertionsOff


Correct Option: A