Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Explain the use of header files in C and C++. Why doesn\'t Java use header files

ID: 3905431 • Letter: E

Question

Explain the use of header files in C and C++. Why doesn't Java use header files?

Supplement 1. Consoder the following C program:

void fun(void) {

    int a, b, c;   /* definition 1 */

    ......

    while (...) {

        int b, c, d; /* definition 2 */

        ......      <---- point 1

        while (...) {

            int c, d, e; /* definition 3 */

            ......   <---- point 2

            }

        ......   <---- point 3

    }

......   <----- point 4

}

For each of the four marked points in this function, list each viible variable, along with the number of definition statement that defines it.

For example: (your answer must be in the same format)

point 1:    a     1

                 b     2

                 c     2

                 d     2

Explanation / Answer

USE OF HEADERS :

Header files contain definitions of Functions and Variables, which is imported or used into any C++ program by using the pre-processor #include statement. Header file have an extension ".h" which contains C++ function declaration and macro definition. Actually header files provide us so many functions that we not need to write all the time, we can create header and that can be used for any another program designing, that also saves time.

In case of Java, as we know everything is a class . So all the predefined functions are put inside a class and these classes (Java files) are further put inside different different folders (Packages). same like header file in C and C++ where they also contains functions variable, but not as Class in java, thats the only difference.

For you to use those functions you will need to import (similar to #include in C/C++) those particular classes containing those functions.

In simple word java imports class and C++/C imports header file.

point 1: a=1,b=2,c=2,d=2
point 2: a=1,b=2,c=3,d=3,e=3
point 3: a=1,b=2,c=2,d=2
point 4:a=1,b=1,c=1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote