2
Q:

main() {

int i;

printf("%d",scanf("%d",&i)); // value 10 is given as input here

}

A) 1 B) 2
C) 3 D) 4

Answer:   A) 1



Explanation:

Scanf returns number of items successfully read and not 1/0. Here 10 is given as input which should have been scanned successfully. So number of items read is 1.

Subject: Java
Q:

What is the difference between method overriding and overloading?

Answer

Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1600
Q:

If a method is declared as protected, where may the method be accessed?

Answer

A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2254
Q:

What do you understand by private, protected and public?

Answer

These are accessibility modifiers. Private is the most restrictive, while public is the least restrictive. There is no real difference between protected and the default type (also known as package protected) within the context of the same package, however the protected keyword allows visibility to a derived class in a different package.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1580
Q:

I don't want my class to be inherited by any other class. What should i do?

Answer

You should declared your class as final. But you can't define your class as final, if it is an abstract class. A class declared as final can't be extended by any other class.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

2 5908
Q:

What is the impact of declaring a method as final?

Answer

A method declared as final can't be overridden. A sub-class can't have the same method signature with a different implementation.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1500
Q:

What is a package?

Answer

Package is a collection of related classes and interfaces. package declaration should be first statement in a java class.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 1574
Q:

What is difference between Path and Classpath?

Answer

Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1690
Q:

What is Thread ?

Answer

A thread is a lightweight subprocess, a smallest unit of processing. It is a separate path of execution. It shares the memory area of process.



As shown in the above figure, thread is executed inside the process. There is context-switching between the threads. There can be multiple processes inside the OS and one process can have multiple threads.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1632