5
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:

How to create Directory on the HD?

Answer

To create directory on the HD we use mkDir() method:


boolean mkDir();


This method returns true if the directory is created on HD


This method returns false if the directory is already existing on HD

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1794
Q:

How to create a file on the hard disk by using File class object?

Answer

We can use the following method call:


boolean createNewFile();


This method creates a new file on the HD. 


 


If a file is already existing with the name given in the constructor then this method does not creates file on HD.


If file is successfully created then this method returns true.


If file is already existing on the HD then this method returns false.


This method may throw IOException whenever IO error is generated while creating file on HD.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1629
Q:

Why interface data is public?

Answer

to access non-public data outside class getter methods be defined but we cannot define a  method inside interface we can declared a method inside interface.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 4393
Q:

Why interface data is final?

Answer

bcoz interface does not contains any initializers and constructors to initialize its data members.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1895
Q:

Why interface data is static?

Answer

Interface data is static data why bcoz interface supports multiple inheritance.


if inteface data is non-static then there is chance for replication of the data (bcoz of replication of data ambiguity problem occurs )

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1678
Q:

What is abstract method?

Answer

abstract method is a method declared with abstract modifier but  with out body.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1753
Q:

why protected modifier?

Answer

Outside the package if any other class other than JVM calls the finalize method our class then it is not allowed

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2059
Q:

What is the use of tostring() method?

Answer

If we print any object by using println() or print() methods.


The println() or print() methods internally calls tostring() method and prints the return value of toString() method.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1644