Tag: programming languages

Questions Related to programming languages

  1. It is possible for more than two threads to deadlock at once.

  2. The JVM implementation guarantees that multiple threads cannot enter into a

  3. Deadlocked threads release once their sleep() method's sleep duration has expired.

  4. Deadlocking can occur only when the wait(), notify(), and notifyAll() methods are

  5. It is possible for a single-threaded application to deadlock if synchronized blocks are

  6. . If a piece of code is capable of deadlocking, you cannot eliminate the possibility of


Correct Option: A,F
  1. public int blipvert(int x) { return 0; }

  2. private int blipvert(int x) { return 0; }

  3. private int blipvert(long x) { return 0; }

  4. protected long blipvert(int x) { return 0; }

  5. protected int blipvert(long x) { return 0; }

  6. protected long blipvert(long x) { return 0; }


Correct Option: A,C,E,F

Which of the following denotes file modes that can be used in C program?

  1. "r"

  2. "w"

  3. "a"

  4. all the above


Correct Option: D
Explanation:

To solve this question, the user needs to know about file modes in C programming.

In C programming, the file modes are used to specify the type of access that is required to open the file. Each mode represents a different type of operation that can be performed on the file. The three most commonly used file modes are "r" for reading, "w" for writing, and "a" for appending.

Option D is correct because all of the given options denote file modes that can be used in a C program.

Option A ( "r" ) is used to open a file for reading purposes.

Option B ( "w" ) is used to open a file for writing purposes. If the file already exists, the contents of the file are overwritten. If the file does not exist, a new file is created.

Option C ( "a" ) is used to open a file for appending purposes. If the file already exists, new data is written to the end of the file. If the file does not exist, a new file is created.

Therefore, the answer is: D

Given: 1. class Super { 2. private int a; 3. protected Super(int a) { this.a = a; } 4. } ... 11. class Sub extends Super { 12. public Sub(int a) { super(a); } 13. public Sub() { this.a = 5; } 14. } Which two, independently, will allow Sub to compile? (Choose two.)

  1. Change line 2 to:public int a;

  2. Change line 2 to:protected int a;

  3. Change line 13 to:public Sub() { this(5); }

  4. Change line 13 to:public Sub() { super(5); }


Correct Option: C,D

Given: 31. // some code here 32. try { 33. // some code here 34. } catch (SomeException se) { 35. // some code here 36. } finally { 37. // some code here 38. } Under which three circumstances will the code on line 37 be executed? (Choose three.)

  1. The instance gets garbage collected.

  2. The code on line 33 throws an exception.

  3. . The code on line 35 throws an exception

  4. The code on line 31 throws an exception

  5. The code on line 33 executes successfully


Correct Option: B,C,E