Second-ordered characterization of generalized convex functions and their applications in optimization problems