I want to develop an app for my class. Can that app work on my friends aka class mates device without uploading it on the google play.If possible then how?
Yeah it is Possible.
I think you are developing your app using Android Studio. In Android Studio go to the option Build -> Build APK for building your app. Then you can share your app with your friends. But Android requires that all APKs be digitally signed with a certificate before they can be installed. So you need to sign your app. Here is a tutorial for building signed app. Then Click on Build -> Build signed APK for building your app.
I want to develop an app for my class. Can that app work on my friends (a.k.a. classmates) device without uploading it on Google Play (Store)?
Short answer, Yes.
Upon development of your Android App, you may choose to export it as an APK, distribute it to your desired users, and have them install it directly. Do make sure that Installing from Unknown Sources is enabled.
Regarding the development of a chat app mentioned in the comments, I support what @GiantTree mentions that you should post that type of questions in StackOverflow.
With that said, when you are still planning on developing the app (presuming that you already know some dev knowledge when it comes to Android), I suggest you follow this Firebase Code Lab.
Android Studio can make signed apk file. Make your apk file, copy file to sdcard in your phone, and install.