Interview Questions

Q:

void waitForSignal() {

Object obj = new Object();

synchronized (Thread.currentThread()) {

obj.wait();

obj.notify();

}

}

Which statement is true?

A) This code can throw an InterruptedException. B) This code can throw an IllegalMonitorStateException.
C) This code can throw a TimeoutException after ten minutes D) All the above
 
Answer & Explanation Answer: B) This code can throw an IllegalMonitorStateException.

Explanation:

It will throw  IllegalMonitorStateException.

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

6 22789
Q:

public abstract class Shape {

private int x;

private int y;

public abstract void draw();

public void setAnchor(int x, int y) {

this.x = x;

this.y = y;

}

}

Which two classes use the Shape class correctly?

A) public class Circle implements Shape { private int radius; B) public abstract class Circle extends Shape { private int radius; }
C) public class Circle extends Shape { private int radius; public void draw(); D) None
 
Answer & Explanation Answer: B) public abstract class Circle extends Shape { private int radius; }

Explanation:

Only B is true

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 22442
Q:

What is a Non-PO Invoice?

Answer

A non-po is an invoice which does not have po(purchase order).However, these invoices requires approval for authorized person/persons to process for payment.


What_is_a_Non-PO_Invoice1558075538.jpg image

Report Error

View answer Workspace Report Error Discuss

Subject: Accounts Payable Exam Prep: Bank Exams
Job Role: Bank Clerk , Bank PO

26 22202
Q:

public class Threads2 implements Runnable {

public void run() {

System.out.println("run.");

throw new RuntimeException("Problem");

Which among the following is true?

}

public static void main(String[] args) {

Thread t = new Thread(new Threads2());

t.start();

System.out.println("End of method.");

}

}

A) java.lang.RuntimeException: Problem B) run. java.lang.RuntimeException: Problem
C) End of method. java.lang.RuntimeException: Problem D) End of method. run. java.lang.RuntimeException: Problem
 
Answer & Explanation Answer: D) End of method. run. java.lang.RuntimeException: Problem

Explanation:

Only D can be true

Report Error

View Answer Report Error Discuss

Filed Under: Java

0 21972
Q:

What is function prototyping? What are its advantages?

Answer

Function prototyping is a function declaration statement that tells the compiler about the return type of the function and the number as well as type of arguments required by the function at the time of calling it.


Syntax:


return_type function_name( type1 arg1, type 2 arg2, ... );


 


Advantages of function prototype :


- It helps the compiler in determining whether a function is called correctly or not. Each time when a function is called, its calling statement is compared with its prototype. In case of any mismatch, compiler reports an error.


- A function must be defined before calling it. But prototyping allows a function to be called before defining it.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

34 21712
Q:

Which is more effective while calling the functions?

A) call by value B) call by reference
C) call by pointer D) none
 
Answer & Explanation Answer: B) call by reference

Explanation:

In the call by reference, it will just copy the address of the variable to access it, so it will reduce the memory in accessing it.

Report Error

View Answer Report Error Discuss

Filed Under: C++

15 21453
Q:

Which tag is used to display the numbered list?

 

1) <ol> </ol>    2) <li></li>     3) <ul> </ul>    4) <dl> </dl>

A) 1 B) 2
C) 3 D) 4
 
Answer & Explanation Answer: A) 1

Explanation:

Use HTML tag <ol> element to define an ordered list.

Use the HTML type attribute to define the numbering type. Use the HTML <li> element to define a list item. Use the HTML <dl> element to define a description list.

 

Hence, as numbered list come under ordered list tag <ol> tag is used for numbered list.

Report Error

View Answer Report Error Discuss

12 21128
Q:

Which of the following gives the memory address of the first element in array?

A) array[0]; B) array[1];
C) array(2); D) array;
 
Answer & Explanation Answer: D) array;

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++

21 21067