3i Infotech Papers: Sample Questions 877 - 879 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 877

» Basic CS » Operating System

Short Answer Question▾

Write in Short

What is the precedence order from high to low, of the symbols

Explanation

  • When two operators share an operand the operator with the higher precedence goes first.

  • is treated as ,

  • is treated as since multiplication has a higher precedence than addition.

  • Symbols arranged in precedence order are.

Question number: 878

» Basic CS » Operating System

Short Answer Question▾

Write in Short

Can there be at least some solution to determine the number of arguments passes to a variable argument list function?

Explanation

  • Yes, it can be done using a control parameter before the variable argument list that determines how many argument will follow.

  • The printf () function uses a string parameter as the control parameter.

  • The number of escape sequence in the string determines the number of argument that are expected to follow, each escape sequence in the string is expanded from left to right according to the arguments that follow.

  • A similar approach can be used to pass the number of arguments that will follow a named argument.

Question number: 879

» Languages » Java

Essay Question▾

Describe in Detail

How does thread synchronization occur in a monitor?

Explanation

Understanding of java monitor.

Understanding of Java Monitor.

Understanding of java monitor.

  • A monitor defines a lock and condition variables for managing concurrent access to shared data.

  • The monitor uses the lock to ensure that only a single thread is active in the “monitored” code at any time.

  • Always only one thread can lock an object to gain access to critical section.

  • Following example illustrates the code.

Example:

class MethodLevel

{

SharedResource x, y;

public synchronized void method ()

{

// multiple threads can not access

}

public synchronized void method2 ()

{

// multiple threads can’t access

}

public void method3 ()

{

// not synchronized

// multiple threads can access

}

}

class BlockLevel

{

// shared among threads

SharedResource x, y;

// dummy objects for locking

Object xLock = new Object (), yLock = new Object ();

public void method1 ()

{

synchronized (xLock)

{

// access x here. thread safe

}

// do something here but don’t use

SharedResource x, y;

synchronized (xLock)

{

synchronized (yLock)

{

// access x, y here. thread safe

}

}

// do something here but don’t use

SharedResource x, y;

}

}