Skip to main content

Posts

Showing posts from 2016

Declare And Handler-1

Əgər bir xəta yaranarsa program dayanır->thrown created Əgər bir xəta sıfıra bölmə xətasıdırsa,tutulan catch tipi Arithmetic Exception deyilsə,process dayanır, Əgər xəta müəyyən olunub,catch tutularsa program çalışır Məsələn programda xəta meydana gəlir,bu xəta declare(throws Exception) edilib,əgər xəta handler(catch) tutulmasa program dayanır-->thrown created əgər xəta tutularsa process (program çalışmaqda)davam edir

Identify benefits of using ArrayList over array in software development.

ArrayList supports dynamic arrays that can grow as needed. In Java, standard arrays are of a fixed length. After arrays are created, they cannot grow or shrink, which means that you must know in advance how many elements an array will hold. But, sometimes, you may not know until run time precisely how large of an array you need. To handle this situation, the collections framework defines ArrayList. In essence, an  ArrayList is a variable-length array of object references. That is, an ArrayList can dynamically increase or decrease in size. Array lists are created with an initial size. When this size is exceeded, the collection is automatically enlarged.

StringBuilder and String Example

StringBuilder sb = new StringBuilder( "append" ); StringBuilder sb1 = new StringBuilder( "append" ); String s = "append" ; String oldSb = sb.toString(); System. out .println(s==oldSb); //false System. out .println(s==sb.toString().intern()); //true System. out .println(sb1==sb); //false System. out .println(sb1.toString()==sb.toString()); //false System. out .println(sb1.toString().intern()==sb.toString().intern()); //true System. out .println(sb1.toString().equals(sb.toString())); //true

Static Variables and Methods

Static Variables and Methods The static modifier is used to create variables and methods that will exist independently of any instances created for the class. In other words, static members exist before you ever make a new instance of a class, and there will be only one copy of the static member regardless of the number of instances of that class. In other words, all instances of a given class share the same value for any given static variable. We'll cover static members in great detail in the next chapter.    Things you can mark as static: Methods Variables A class nested within another class, but not within a method (more on this in Chapter 8). Initialization blocks    Things you can't mark as static: Constructors (makes no sense; a constructor is used only to create instances) Classes (unless they are nested) Interfaces Method local inner classes (we'll explore this in Chapter 8) Inner class methods and instance variables Local variables They...

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) -m...

Thread with Exception practice

(Only OCP) public class TwoThreads {     static Thread laurel, hardy; public static void main(String[] args) {     laurel = new Thread() { public void run() {       System.out.println("A");       try {             hardy.sleep(1000);       } catch (Exception e) {             System.out.println("B");       }             System.out.println("C");       } };       hardy = new Thread() {       public void run() { System.out.println("D");       try {             laurel.wait();       } catch (Exception e) {             System.out.println("E");       }             System.out.println("F");       } };       ...

Exception practice

Which of the following can be inserted into Lion to make this code compile? (Choose all that apply) class HasSoreThroatException extends Exception {} class TiredException extends RuntimeException {} interface Roar {   void roar() throws HasSoreThroatException; } class Lion implements Roar {   // INSERT CODE HERE } A. public void roar(){} B. public void roar() throws Exception{} C. public void roar() throws HasSoreThroatException{} D. public void roar() throws IllegalArgumentException{} E. public void roar() throws TiredException{} Explain : Mehod implement/overriden olunan zaman compiler method-un exceptions list-nə baxır.Əgər checked exception varsa overridden olunan methodda ya həmin exception və ya subclass ı qeyd olunmalıdı ya da heç bir exception qeyd olunmamalıdı method exceptions listdə.Əks halda compiler error verəcək.RuntimeException unckecked exception tipi olduğu üçün compiler görmür onu.Ona görə bu zaman normal compile olunur. Cavab ACDE

Detailed Demonstration of Deployment of GlassFish Server 4.1

The steps are as follows: Step 1: Adding Java PPA Addition of Python-Software Properties #apt -get install python-software-properties Addition of Java using add-apt-repository #add -apt-repository ppa:webupd8team/java Updation of System #apt -get update Step-2 Installing Oracle JDK8 #apt -get install oracle-java8-installer Step-3 Setting "Java_Home" Variable # vim /etc/environment Add the following line to the bottom JAVA_HOME="/usr/lib/jvm/java-8-oracle" #source  /etc/environment #java  -version Step-4 Installing GlassFish 4.1 #cd  /tmp Download the Glassfish Software #wget  ' http://download.java.net/glassfish/4.... Install Unzip #apt -get install unzip #unzip  glassfish-4.1.zip -d /opt Step-5 Setting GlassFish Path #vim  ~/.profile Add the following Lines export PATH=/opt/glassfish4/bin:$PATH #source  ~/.profile Step-6 Starting GlassFish Server #asadmin  start-domain Open Web Browser type:  http://ipaddress:8080   :4848 is admin login...

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

Procedure for installing and setting Sun JDK Java on Default Amazon Linux AMI

# First verify the version of Java being used is not SunJSK. java -version # Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.rpm # Rename the file downloaded, just to be nice mv jdk-7u1-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u1-linux-i586.rpm # Install Java sudo rpm -i jdk-7u1-linux-i586.rpm  # Check if the default java version is set to sun jdk java -version # If not then lets create one more alternative for Java for Sun JDK sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_01/bin/java 20000 # Set the SUN JDK as the default java sudo /usr/sbin/alternatives --config java # Verify if change in SDK was done. java -version source

install FFmpeg and FFmpeg commands

install FFmpeg  sudo add-apt-repository ppa:mc3man/trusty-media sudo apt-get update  sudo apt-get install ffmpeg To split from vob to mp4 without losing quality Syntax: ffmpeg -i sourcdFile.vob -ss [start time] -t [total seconds] DestinationFile.mp4 Example: ffmpeg -i sourcdFile.vob -ss 00:00:02 -t 42 DestinationFile.mp4

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

wget with command in GNU/LINUX

 -r recursively   -nH (--no-host-directories) cuts out hostname --cut-dirs=X (cuts out X directories) --reject  --accept @javad:~$ wget -m --reject .html,css.js,png,gif,txt 'http://www.example.com' @javad:~$ wget -m --reject .html,css,js,png.7z,pdf --accept .txt 'http://www.example.com' @javad:~$ wget -r -np  --reject .html,css,js,png.7z,pdf --accept .txt 'http://www.example.com'

Swap File creation on GNU/Linux

cavadjava@Javad:~$ htop cavadjava@Javad:~$ free -m               total        used        free      shared  buff/cache   available Mem:           7930        3468         144         820        4317        3275 Swap:          4052           0        4052 cavadjava@Javad:~$ cd / cavadjava@Javad:/$ sudo fallocate -l 12G /swapfile [sudo] password for cavadjava: cavadjava@Javad:/$ sudo chmod 600 swapfile cavadjava@Javad:/$ sudo mkswap /swapfile Setting up swapspace version 1, size = 12 GiB (12884897792 bytes) no label, UUID=e7407f29-8bb0-4fec-ba0e-e0d13c2c7ec5 cavadjava@Javad:/$ sudo swapon /swapfile cavadjava@Javad:/$ sudo swapon -s Filename Type Size Used Priority /dev/sda5     ...