I have a class like this:  public class DateS extends Date {     public DateS yesterday(){         Calendar cal = Calendar.getInstance();         cal.setTime(this);         cal.add(Calendar.DAY_OF_YEAR, -1);         return (DateS) cal.getTime();     } }   It can be successfully built. At runtime, when I call date.yesterday(), a Cannot cast 'java.util.Date' to 'myproject.package.DateS' are throwed.  I need to know why and what can I do to fix this.
Upcasting is allowed in Java, however downcasting gives a compile error.   The compile error can be removed by adding a cast but would anyway break at the runtime.   In this case why Java allows downcasting if it cannot be executed at the runtime? Is there any practical use for this concept?   public class demo {   public static void main(String a[]) {       B b = (B) new A(); // compiles with the cast,                           // but runtime exception - java.lang.ClassCastException   } }  class A {   public void draw() {     System.out.println("1");   }    public void draw1() {     System.out.println("2");   } }  class B extends A {   public void draw() {     System.out.println("3");   }   public void draw2() {     System.out.println("4");   } }
(a) Determine which Fibonacci numbers are even. Use a form of mathematical induction to prove your conjecture. (b) Determine which Fibonacci numbers are divisible by 3. Use a form of mathematical induction to prove your conjecture  I understand that for part a that all multiples of 3 of n are even. So F(0),F(3),F(6)... I just don't understand how to prove it.  For part B it is the same thing except multiples of 4  Please help, thank you! Multiple monitors, multiple workspaces? I connected my laptop to my LCD. Using the laptop display hotkey I can switch between different modes - only laptop monitor on, only LCD monitor on, both on and display the same view, both on and the desktop is stretched (divided).  But, I'm looking for something else - I would like to have two workspaces, one visible on the laptop monitor and the other on the LCD.  Is that possible? Confused about complex numbers I am confused about something: \begin{eqnarray}     (e^{2 i \pi})^{0.5} = (e^{2 i \pi \cdot 0.5})= e^{i \pi}=-1 \end{eqnarray} but \begin{eqnarray}      e^{2 i \pi}=1~ and~ 1^{0.5}=1  \end{eqnarray} where is my mistake??  thanks Can decimal numbers be considered "even" or "odd"? Why am I getting authentication errors for packages from an Ubuntu repository? I'm experimenting with VPNs, so I wanted to install pptpd.  john@desktop:~$ sudo apt-get install pptpd [sudo] password for john:  &lt;snip&gt; The following extra packages will be installed:   bcrelay The following NEW packages will be installed:   bcrelay pptpd 0 upgraded, 2 newly installed, 0 to remove and 11 not upgraded. Need to get 90.5 kB of archives. After this operation, 442 kB of additional disk space will be used. Do you want to continue [Y/n]? y   And everything runs fine until I get down to here:  WARNING: The following packages cannot be authenticated!   bcrelay pptpd Install these packages without verification [y/N]? n E: Some packages could not be authenticated   No authentication?  I'm no security expert, but I'm fairly sure that's a bad thing.  So I .  john@desktop:~$ apt-cache policy pptpd pptpd:   Installed: (none)   Candidate: 1.3.4-3ubuntu1   Version table:      1.3.4-3ubuntu1 0         500 http://us.archive.ubuntu.com/ubuntu/ natty/main i386 Packages john@desktop:~$ apt-cache policy bcrelay bcrelay:   Installed: (none)   Candidate: 1.3.4-3ubuntu1   Version table:      1.3.4-3ubuntu1 0         500 http://us.archive.ubuntu.com/ubuntu/ natty/main i386 Packages   They're coming from Ubuntu.com and not being properly authenticated?  What's going on here? ${!FOO} and zsh ${!FOO} performs a double substitution in bash, meaning it takes the (string) value of FOO and uses it as a variable name. zsh doesn’t support this feature.  Is there a way to make this work the same in bash and zsh?  Background:  I’ve got a list of environment variables, like  PATH MAIL EDITOR   and want to first print the variable names and afterwards their values.  This works in bash but not zsh:    for VAR in LIST do         echo $VAR         echo ${!VAR} done   It should be somehow possible “the old way” with eval, but I can’t get it to work:  for VAR in LIST do         echo $VAR         echo `eval \$$VAR` done   I’m never going to understand why I can’t simply do arbitrary deep substitutions like ${${VAR}} or even ${${${VAR}}} if need be, so an explanation for that would be nice, too. Will getting a Software Testing Certification benefit me in my career? I have 2 years of experience in manual testing, and I am currently learning automation testing in my spare time. I was thinking that will getting a foundation/entry testing certification really help me in promotions and increase my salary or just increase my knowledge and nothing more? Even if I wish to try to get certified and pass the exams, is it too late or can I try after a few more years?  Kindly suggest! It  to disable internet search results in start menu searches before the Windows 10 Creators Update, but I've just clean installed a new Windows 10 Pro image and that setting is gone. Is there some way to disable it through editing the registry/etc? "Failed to create user" due to regular expression error I'm running Ubuntu 12.10 desktop 32 bit. Currently I have only a user, type administrator. I'd like to create another administrator user but I keep getting the following error:  Failed to create user GDBus.Error:org.freedesktop.Accounts.Error.Failed: running '/usr/sbin/adduser' failed: /usr/sbin/adduser returned an error (1): adduser: Please enter a username matching the regular expression configured via the NAME_REGEX[_SYSTEM] configuration variable.  Use the `--force-badname' option to relax this check or reconfigure NAME_REGEX.  Any suggestion is appreciated. Let us consider that $u\in C^2(\Omega)\cap C^0(\Omega)$ and satisfying the following equation .  $\Delta u=u^3-u , x\in\Omega$ and   $u=0 $   in  $\partial \Omega$  $\Omega \subset \mathbb R^n$ and bounded .   I need hints to find out what possible value $u$ can take ?  Thank you for ur hints in advance . Process Unicode files with BOM correctly with POSIX tools Which Defiant was shown in ST: First Contact? In Memory Alpha, the page on the  states that two Defiant-class ships had that name: the prototype Defiant, and a successor, the U.S.S. Sao Paulo, which was assigned to DS9 and renamed Defiant after the loss of the original. All of this happened during the DS9 series.  In the Star Trek: First Contact movie, the Defiant participates in the opening battle, where a Borg Cube penetrates the Sol system's defenses and besieges Earth. Worf is in command, and is transported out of the crippled Defiant along with whatever's left of his crew by the Enterprise; out-of-universe, this is a rather transparent method to get Worf back into the TNG side of things after the events of ST: Generations, when he moved to DS9 as tactical officer and unofficial envoy to the Klingon Empire.  The question is, was Worf's Defiant in the movie the original, or the Sao Paulo? This would primarily depend on where the movie falls in the overall canon timeline. According to in-movie dialog, whichever one it was was salvageable and therefore would have survived the movie, so the movie would have had little impact on the canon of any running TV series at the time. Sorting list based on values from another list boolean[] vs. BitSet: Which is more efficient? What is more efficient in terms of memory and CPU usage — an array of booleans or a BitSet? Specific BitSet methods are not used, only get/set/clear (==, =, Arrays.fill respectively for an array). Converting from 7-speed to 10-speed rear wheel My Bridgestone MB-5 currently has a 7-speed rear wheel. I'd like to convert it to a 10-speed. Is this possible? Is it practical? I've been building my own emacs because I want to fix some issues in it and get the bug fixes upstream. However, Ubuntu keeps automatically removing my own built emacs and I have to keep rebuilding and reinstalling it.  Here's my output of apt-cache policy emacs when I went to bed last night:  ~/emacs$ sudo apt-cache policy emacs emacs:   Installed: 26.0.50.aaron-1   Candidate: 46.1   Version table:      46.1 500         500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages         500 http://us.archive.ubuntu.com/ubuntu xenial/main i386 Packages  *** 26.0.50.aaron-1 100         100 /var/lib/dpkg/status   Here it is when I wake up:  ~/emacs$ sudo apt-cache policy emacs [sudo] password for excelsiora: emacs:   Installed: 46.1   Candidate: 46.1   Version table:  *** 46.1 500         500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages         500 http://us.archive.ubuntu.com/ubuntu xenial/main i386 Packages         100 /var/lib/dpkg/status   Why is this package being versioned at 46 instead of 24 or 25? 26 is the currently the highest major emacs version you can get.   I can see that this is a meta-package:   Why is Ubuntu updating software without asking?  Main Question: What am I supposed to do - assign my package version a number higher than 46 just to make it stick?   That seems like a horrible hack, or maybe that's how it's supposed to work? Enable USB debugging (under settings/applications/development) programmatically from within an app Is it appropriate to ask what a public beta sites needs to graduate? I came across  today in a separate question:     The only thing holding [Code Review] back from graduating is the lack of high rep users - there just aren't enough 1k+, 3k+ users on the site, and it can't quite yet sustain an election. Every single thing about CR is ready but that - it's really just a matter of time at this point (and, well, voting).   Almost all the posts about what the criteria for graduation are vague and don't mention specific examples:       The first question specifically asks about 2 beta (now graduated) sites, but the answer is more general, "Look at this blog" with general guidance.  How often are site stats reviewed by the team in charge of betas? And is it appropriate to create meta questions asking where a site stands to get feedback to the community on how to improve? Say $\mathbf{x} \in \mathbb{R}^n$, what is the common notation to extract the first component as an operation?  Something like $\mathcal{P}_j = \mathbf{x}_j$? $\mathbf{x}_j$ is the j-th component.   I need this because I have a function $f(\mathbf{x}) \approx \mathbf{x}$, so I need something like $\mathcal{P}f(\mathbf{x}) \approx \mathbf{x}_j$ since my metric is defined for a single component of $\mathbf{x}_j$. How can I get a command block?