Skip to content Skip to sidebar Skip to footer

Difference Between File, Class And Activity In Android

What's the difference between file, class and activity in android?

Solution 1:

File - It is a block of arbitrary information, or resource for storing information. It can be of any type

Class - Its a compiled form of .Java file . Android finally used this .class files to produce an executable apk

Activity - An activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type it is just a class that can be extended in Android for loading UI elements on view

Solution 2:

Class - A class is a combination of methods, variables and data types. Every Java or Android project must have at least one class.

Example:

publicclassshape{

    publicvoidcircle()
    {
        int A,B,radias;
    }
}

Activity - An Activity is an android class. If we want to use an activity class, we must use extend Activity in your android project.

Example:

publicclassshapeextendsActivity{

    publicvoidcircle()
    {
        int A,B,radias;
    }
}

Solution 3:

File is a file on the filesystem. Class is a Java class. Activity is a specific java class commonly used in Android.

Solution 4:

1) Class is Blueprint of object and you will create as many object you want from same class. You can create new object by “new” keyword. In example below “ArrayList” is class and “obj” is object.

ArrayList<String> obj=newArrayList<String>

2) Activity :- Every program has some starting point. In android Activity is starting point of any application you made. It is basically a GUI of the app. In android app every activity have to inherent directly or indirectly from Activity Class which is predefined in the android system. So activity is also a class but a special one. So you can say that “Every activity is a class but every class is not Activity”.

3) File :- file is used to store data so you can reuse again when you app start.

Solution 5:

An activity is actually a class (click) and if you want to make your own activity you choose this one as parent class. And the source code of classes is defined in files, actually every class should be described in its own file.

That's some basic knowledge of object oriented programming - you might want to have a look here to find more information

Post a Comment for "Difference Between File, Class And Activity In Android"