Skip to main content

Practice Exception OCA Level

(OCA Level)
public class ExceptionClass {
   static String s = "-";
public static void main(String[] args) {
   try {
      throw new Exception();
   } catch (Exception e) {
   try {
      try {
         throw new Exception();
      } catch (Exception ex) {
         s += "ic ";
      }
         throw new Exception();
      } catch (Exception x) {
         s += "mc ";
      } finally {
         s += "mf ";
      }
   } finally {
   s += "of ";
   }
   System.out.println(s);
   }
}
What is the result? (Explanation's required)
A) -ic of
B) -mf of
C) -mc mf
D) -ic mf of
E) -ic mc mf of
F) -ic mc of mf
G) Compilation fails

Explain:
Mürəkkəb struktura malik try ifadəsidir. Belə nümunələrdə gərək ilk öncə kodun compile olunub olunmamasını yoxlayaq, hər şeyin qaydasında olduğuna əmin olduqdan sonra artıq output`u hesablamaq olar. 
Try, catch və ya finally bloklarının içərisində başq
a bir try ifadəsi işlətmək mümkündür, ona görə də birinci catch blokunda verilmiş sintaksis səhv deyil. Sadəcə burada try ifadəsi ilə bağlı bəzi vacib məqamları bilmək lazımdır:
- try bloku təklikdə işlədilə bilməz, ondan sonra mütləq catch və ya finally bloklarından biri gəlməlidir;
- eyni zamanda catch və ya finally blokları ancaq try bloku ilə birgə istifadə edilə bilər, təklikdə istifadə edilə bilməz;
- finally bloku catch blokundan sonra gəlməlidir, əks halda compile xətası verir.
Qeyd olunan bütün qaydalar ödənilir, ona görə də kod normal compile olunur. Artıq output`u hesablamaq olar:
1. 1) blokunda exception baş verir, ona görə də 2) bloku icra edilir;
2. 2.1.1) blokunda exception baş verir və 2.1.2) bloku icra edilir;
3. sonra 2.1) blokunda exception baş verir və 2.2) bloku icra edilir;
4. 2.3) bloku icra edilir;
5. 3) bloku icra edilir.

Cavab: E

Comments

Popular posts from this blog

VMware -> root access is required for the operations you have chosen FIX ubuntu 14.04

Example ~$ wget https://www.vmware.com/go/tryworkstation-linux-64 [sudo] password for javad: *****  --2016-08-11 11:19:10--  https://www.vmware.com/go/tryworkstation-linux-64 Resolving www.vmware.com (www.vmware.com)... 104.86.190.190, 2a02:26f0:c000:183::2ef, 2a02:26f0:c000:190::2ef ..... .... ... .. . .. ... .... .....  ~$ sudo chmod +x tryworkstation-linux-64 ~$ sudo -i ~#  ~# cd / root@javad-quad:/# cd /home/javad/ root@javad-quad:/home/javad# ./tryworkstation-linux-64 Extracting VMware Installer...done. ... Product: VMware® Workstation 12 Pro Version: 12.1.1 build-3770994 licence key: VY1DU-2VXDH-08DVQ-PXZQZ-P2KV8 VF58R

fix audio in kali linux

1. leafpad /etc/pulse/daemon.conf 2. find "default-sample-channels" and change the number -->1-->save-->exit 3. pulseaudio start 4. pulseaudio --start Practice  root@javad:~# sudo leafpad /etc/pulse/daemon.conf  root@javad:~# pulseaudio start E: [pulseaudio] main.c: Too many arguments. root@javad:~# pulseaudio  --start W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).  root@javad:~# reboot