Tag: java

Questions Related to java

  1. 1.information hiding

  2. 2.encapsulation

  3. 3.Inheritance

  4. 4.modularity


Correct Option: B
Explanation:

To solve this question, the user needs to be familiar with the concepts of object-oriented programming and the principles of encapsulation and information hiding.

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

A. 1. information hiding: This option is correct. Information hiding is the practice of encapsulating the internal details of an object and providing access to it only through its member functions. This helps to hide the complexity and implementation details of an object, allowing for better maintainability and preventing unauthorized access to sensitive information.

B. 2. encapsulation: This option is correct. Encapsulation is the practice of bundling data and methods together within a class and providing controlled access to them. It allows for the implementation details of an object to be hidden and accessed only through the defined interface, promoting modularity and code reusability.

C. 3. Inheritance: This option is incorrect. Inheritance is a concept in object-oriented programming where a class derives properties and behaviors from another class. It is not directly related to the practice of providing access to an object only through its member functions and keeping the details private.

D. 4. modularity: This option is incorrect. Modularity refers to the practice of dividing a program into smaller, independent modules that can be developed, tested, and maintained separately. While encapsulation and information hiding contribute to modularity, modularity does not specifically refer to the practice of providing access to an object only through its member functions and keeping the details private.

The Answer is: B. 2. encapsulation

  1. 1.Empty set

  2. 2.one pair a==true,b==false

  3. 3.two pairs in which a==true

  4. 4.two paires in which a!=b

  5. 5.All 4possible combination


Correct Option: C
  1. 1.static,nonstatic class

  2. 2.Inheritance,Composition

  3. 3.Composition,Inheritance

  4. 4.Overriding,Overloading


Correct Option: C
  1. 1.BorderLayout

  2. 2.Ther is no layout

  3. 3.FlowLayout

  4. 4.GridLayout


Correct Option: A
  1. 1.program ignores exceptn

  2. 2.program halts immediately

  3. 3.Program will not compile

  4. 4.None of the above


Correct Option: B

Which are the values in arr after execution of following.. Int[]arr={1,1,0,0,0}; for(int i=2;i < arr.length;i++) arr[i]=arr[i-1]+arr[i-2];

  1. 1.11011

  2. 2.1121

  3. 3.11222

  4. 4.11235

  5. 5.11248


Correct Option: D

AI Explanation

To determine the values in the array arr after executing the given code, let's go through each iteration of the loop:

  1. Before the loop starts: arr = [1, 1, 0, 0, 0]
  2. Iteration 1: arr[2] = arr[1] + arr[0], so arr[2] = 1 + 1 = 2 Updated arr = [1, 1, 2, 0, 0]
  3. Iteration 2: arr[3] = arr[2] + arr[1], so arr[3] = 2 + 1 = 3 Updated arr = [1, 1, 2, 3, 0]
  4. Iteration 3: arr[4] = arr[3] + arr[2], so arr[4] = 3 + 2 = 5 Updated arr = [1, 1, 2, 3, 5]

After executing the code, the final value of arr is [1, 1, 2, 3, 5].

Among the given options, the correct answer is D) 4.11235, as it matches the final values of the array arr.

  1. 1.Robust

  2. 2.Procedural

  3. 3.Distributed

  4. 4.Multithreaded


Correct Option: B
  1. 13

  2. 15

  3. 0

  4. Compiler error


Correct Option: D
  1. internet explorer

  2. Netscape Navigator

  3. Hotjava

  4. Opera


Correct Option: D
  1. 0

  2. -1

  3. -2

  4. compiler error


Correct Option: C