I am being told that pipe class refers to the maximum internal pressure a pipe can safely sustain while pipe schedule refers to the thickness of pipe. But how are they independent , the thickness of pipe will determine how much internal pressure it can sustain. Isn't it ?A 4" Carbon steel pipe of Schedule 40 should have a unique class or it can have different class ?

There are various misunderstandings and misconceptions regarding the classification of piping – and most of these originate primarily because some engineers simply don't employ their common sense. Some would like to pretend that there is an almighty, all-powerful agency somewhere that dictates what a pipe is, will be, and shall be by established and enforced "laws", codes, or "standards". No such animal exists.

You are being told the wrong information if you are told "pipe class refers to the maximum internal pressure a pipe can safely sustain". The important point to bear in mind here is that the pipe itself may not (& in most cases, doesn't) fix the maximum safe pressure allowable on the ENTIRE piping system involved. In most cases, the flanges are the weakest point - and this should be the guiding design factor with regards to allowable pressure in that specific piping class(ification).

A pipe class is a document (normally prepared by an operating or engineering company) for use within its confines and which contains the definition of pipe and all related components that are to be used under a specific pressure, temperature condition – including sometimes the service they are in. A typical definition contains the material specification, type, rating, and dimensional data. It serves as a CLASSIFICATION of piping systems and their application within the process design at hand. A certain pipe schedule is often established for certain services. This is dictated by the classification, based on the need and the application.

A pipe schedule to be used and serves as the basic specification for the pipe thickness and dimensions. You should know that the hoop stress equation is what determines the pipe thickness, so you shouldn't be asking whether the pipe thickness determines the allowable working pressure. You SHOULD KNOW that it does – and under what conditions.

Industrial pipe thicknesses follow a set formula, expressed as the "schedule number" as established by the American Standards Association (ASA) now re-organized as ANSI - the American National Standards Institute. Eleven schedule numbers are available for use: 5, 10, 20, 30, 40, 60, 80, 100, 120, 140, & 160. The most popular schedule, by far, is 40. Schedules 5, 60, 100, 120, & 140 have rarely, if ever, been employed by myself in over 48 years as a practicing engineer. The schedule number is defined as the approximate value of the expression:

Schedule Number = (1,000)(P/S)

Where,

P = the internal working pressure, psigS = the allowable stress (psi) for the material of construction at the conditions of use.

For example, the schedule number of ordinary steel pipe having an allowable stress of 10,000 psi for use at a working pressure of 350 psig would be:

Schedule Number = (1,000)(350/10,000) = 35 (approx. 40)

I can understand your confusion and ignorance from a student's point of view. Students are never exposed to this methodology and are initiated into it when they go into the real world in their first job(s).