Continuous extension of a real function defined on an open interval Let $I\subset\mathbb{R}$ be a compact interval and let $J$ denote its interior.
Consider $f:J\to\mathbb{R}$ being continuous.


*

*Under which conditions does the following statement hold?
$$
\text{There exists a continuous extension $g:I\to\mathbb{R}$ of $f$.}\tag{A}
$$

*Is boundedness of $f$ sufficient for (A)?

 A: Call a continuous function $f:X\to \mathbb{R}$ (where $X$ is some metric spaces) Cauchy continuous if $f$ takes Cauchy sequences in $X$ to Cauchy sequences in $\mathbb{R}$. It is then a classic theorem that a continuous function $f:X\to \mathbb{R}$ admits an extension $\widetilde{f}:\overline{X}\to \mathbb{R}$ (where here $\overline{X}$ denotes the completion of $X$) if and only $f$ is Cauchy continuous.
To see why necessity is obvious note that if we have some Cauchy sequence $(x_n)$ in $X$ then it's convergent in $\overline{X}$ and since $\widetilde{f}:X\to Y$ is continuous we know that $(x_n)$ is carried to some convergent sequence in $\mathbb{R}$, and so in particular, carried to a Cauchy sequence.
The converse pretty much follows (very roughly) by defining $\widetilde{f}$ on $\overline{X}$ by taking some $x\in\overline{X}$, some sequence $(x_n)$ in $X$ converging to $x$, and define $\widetilde{f}(x)=\lim f(x_n)$. This passes the first BS test in the sense that everything ostensibly makes sense. Namely, since $(x_n)$ converges in $\widetilde{X}$ it's Cauchy and so $(f(x_n))$ is Cauchy and so converges in $\mathbb{R}$. One needs to check that this is well-defined (i.e. independent of choice of sequence) and continuous.
The intuition behind why the above is true is fairly simple (I hope I'm not insulting you by spelling it out) as well. Namely, the only real obstruction to extending to a function on $\overline{X}$ is that $\lim f(x_n)$ doesn't converge for some convergent sequence $(x_n)$ in $X$, since this is the only sensible way to extend $f$. But, think about it, $\lim f(x_n)$ will converge (since $\mathbb{R}$ is complete) if and only if $(f(x_n))$ is Cauchy. So, the only problem in extending a function on $X$ to a function on $\overline{X}$ is the existence of Cauchy sequences in $\overline{X}$ whose image under $f$ is not Cauchy. But, practically by definition of $\overline{X}$ we can reduce this to worrying about Cauchy sequences in $X$ whose image under $f$ isn't Cauchy--tada!
So, in your example, $I$ is the completion of $J$ so that $f$ admits an extension from $I$ to $J$ if and only if $f$ is Cauchy continuous.
No, the classic example being that $x\mapsto \sin\left(\frac{1}{x}\right)$ is continuous on $(0,1)$ but has no extension to $[0,1]$--this 
A: Hint for 1: think about limits.
Hint for 2: try $f(x) = \sin(h(x))$ for suitable functions $h$.
A: Call $I = [a, b]$ with $-\infty < a < b < \infty$. Such an extension exists if and only if both $\lim_{x\to a^+} f(x)$ and $\lim_{x\to b^-} f(x)$ exist, and in fact these values become the values of the extension. (The proof is left as a simple exercise.) With this in mind, boundedness is not sufficient due to previously mentioned functions, such as $\sin\left(\frac{1}{x}\right)$ on $(0, 1)$.
