Tuesday 4 July 2017



       Welcome to programming practice 

Sunday 25 June 2017

Features of Java

Features of any programming language is nothing but the service or basic facilities provided by the language to the programmers. The java language provides the following features.



Simple:-

  • Looks familiar to existing programmers: related to C and C++:
  • Omits many rarely used, poorly understood, confusing features of C++, like operator overloading, multiple inheritance, automatic coercions, etc.
  • Contains no goto statement, but break and continue
  • Has no header files and eliminated C preprocessor
  • Eliminates much redundancy (e.g. no structs, unions, or functions)
  • has no pointers
  • Added features to simplify:
  • Garbage collection, so the programmer won't have to worry about storage management, which leads to fewer bugs.
  • A rich predefined class library



Object-Oriented:-

Java is an object-oriented language, which means that you focus on the data in your application and methods that manipulate that data, rather than thinking strictly in terms of procedures.
In an object-oriented system, a class is a collection of data and methods that operate on that data. Taken together, the data and methods describe the state and behavior of an object. Classes are arranged in a hierarchy, so that a subclass can inherit behavior from its superclass.
Java comes with an extensive set of classes, arranged in packages, that you can use in your programs.

Portable:-

java goes further than just being architecture-neutral:

  • no "implementation dependent" notes in the spec (arithmetic and evaluation order)
  • standard libraries hide system differences
  • the Java environment itself is also portable: the portability boundary is POSIX compliant

  •  Platform Independent:-

    A platform is the hardware or software environment in which a program runs.
    There are two types of platforms software-based and hardware-based. Java provides software-based platform.
    The Java platform differs from most other platforms in the sense that it is a software-based platform that runs on the top of other hardware-based platforms. It has two components:
    1. Runtime Environment
    2. API(Application Programming Interface)
    Java code can be run on multiple platforms e.g. Windows, Linux, Sun Solaris, Mac/OS etc. Java code is compiled by the compiler and converted into bytecode. This bytecode is a platform-independent code because it can be run on multiple platforms i.e. Write Once and Run Anywhere(WORA).

    Secured:-

    Security is an important concern, since Java is meant to be used in networked environments. Without some assurance of security, you certainly wouldn't want to download an applet from a random site on the net and let it run on your computer. Java's memory allocation model is one of its main defenses against malicious code (e.g can't cast integers to pointers, so can't forge access). Furthermore:

  • access restrictions are enforced (public, private)
  • byte codes are verified, which copes with the threat of a hostile compiler
  • Robust:-

    Java has been designed for writing highly reliable or robust software:

  • language restrictions (e.g. no pointer arithmetic and real arrays) to make it impossible for                     applications to smash memory (e.g overwriting memory and corrupting data)
  • Java does automatic garbage collection, which prevents memory leaks
  • extensive compile-time checking so bugs can be found early; this is repeated at runtime for                  flexibilty and to check consistency

  • Architectural neutral:-



  • compiler generates bytecodes, which have nothing to do with a particular computer architecture
  • easy to interpret on any machine
  • Dynamic:-

    Java was designed to adapt to an evolving environment:


  • Even after binaries have been released, they can adapt to a changing environment
  • Java loads in classes as they are needed, even from across the network
  • It defers many decisions (like object layout) to runtime, which solves many of the version                    problems that C++ has
  • Dynamic linking is the only kind there is
  • Interpreted:-

    It is one of the highly interpreted programming languages.

    High performance:-

    Java is faster than traditional interpretation since byte code is "close" to native code still somewhat slower than a compiled language (e.g., C++)

    Multi-threaded:-

    A thread is like a separate program, executing concurrently. We can write Java programs that deal with many tasks at once by defining multiple threads. The main advantage of multi-threading is that it doesn't occupy memory for each thread. It shares a common memory area. Threads are important for multi-media, Web applications etc.

    Distributed:-

    We can create distributed applications in java. RMI and EJB are used for creating distributed applications. We may access files by calling the methods from any machine on the internet.

    Saturday 24 June 2017

    How to Set Path and Classpath in Java

    Path Variable

    Path variable is set for providing path for all Java tools like java, javac, javap, javah, jar, appletviewer which are used in java programming. All these tools are available in bin folders so we set path upto bin folders.

    Classpath Variable

    Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar.

    Why set path ?

    The following programming error is generally for all Java programmers when they compile any Java program.

    'javac' is not recognized as an internal or external command, operable program or batch file.


    When you get this type of error, then your operating system cannot find the Java compiler (javac). To solve this error you need to set the PATH variable.

    Javac is a tool which is available in bin folder so you must set the PATH upto bin folder. In a bin folder all tools are available like javap, javah, jar, javac, java, appletviewer etc. All these tools are used for different-different purpose.

    bin folder

    set the path and classpath

    Go on my computer icon and right click, after that click on properties option.
    My computer properties
    Now click on advance setting
    Advance settings
    Click on advance
    advance
    Click on Advance variables
    Environment variable
    Click on new button which is below the first box.
    Environment variable
    Now one dilog box is appear, now ignore this but do not close.
    Path and classpath
    Now open my computer open c:/ > Programs Files > java > java1.6.0 > bin copy this path
    Path and classpath
    Now come back on previous open dilogbox and write variable name 'path' and for variable value paste all copied path upto the bin folder. Put .; at the end. It (.) selects all the tools from the bin folder.
    Path and classpath
    Now open my computer open c:/ > Programs Files > java > java1.6.0 > jre > lib > rt.jar copy this path
    Note: rt.jar is available in lib folder this jar files contains all classes of jdk.
    Path and classpath
    Now again come back on Environment variable dilogbox and click on new. Now one box is open and write path variable as 'classpath' and for variable value paste all copied paths upto rt.jar. Put .; at the end. It (.) selects all the classes from lib folder.
    Path and classpathPath and classpath  

    NOTE:-Finally after set classpath Restart your system, or you can re-open command prompt


    differences are like... 


    1).Path is an environment variable which is used by the operating system to find the executables. 

    Classpath is an environment variable which is used by the Java compiler to find the path, of classes.ie in J2EE we give the path of jar files. 


    2).PATH is nothing but setting up an environment for operating system. Operating System will look in this PATH for executables. 

    Classpath is nothing but setting up the environment for Java. Java will use to find compiled classes 

    3).Path refers to the system while classpath refers to the Developing Envornment. 

    In path we set the path of executables while in 
    classpath we set path of jars for compiling classes.

    Friday 23 June 2017

    History of Java

    Java language developed by company Sun Microsystems and the creator is Jamesh Gosling.
    James Gosling

    Story behind development of Java

    Sun Microsystems Started by a group of the students who are studing in Standard University. These people found the problem in their room with electronic consumable remote. That means one electronic consumable control doesn't work on another electronics consumable. These people want to develop a common remote control which is controlling all the electronic consumables so they contact James Gosling and requested for the projects. Sun Microsystems started by a group of students out of them one person also Indian whose name Vinode Khosla.
    James Gosling and his team members given the project name as Green started in the year 1990 and common remote control completed in the year 1992.
    The James Gosling team develops a new language called as OAK But this name is already selected by any other company renamed as Java, but Java has no meaning representation of Island in Indonesia. The unofficial abbreviation of Java is Just Another Virtual Analyzer (JAVA).

    Java Version History

    Now a day 8 versions of java are released, which is listed below with realizing date.
    • JDK Alpha and Beta (1995)
    • JDK 1.0 (23rd Jan, 1996)
    • JDK 1.1 (19th Feb, 1997)
    • J2SE 1.2 (8th Dec, 1998)
    • J2SE 1.3 (8th May, 2000)
    • J2SE 1.4 (6th Feb, 2002)
    • J2SE 5.0 (30th Sep, 2004)
    • Java SE 6 (11th Dec, 2006)
    • Java SE 7 (28th July, 2011)
    • Java SE 8 (18th March, 2014)

    Introduction to java programming

    Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991. The target of Java is to write a program once and then run this program on multiple operating systems. The first publicly available version of Java (Java 1.0) was released in 1995. Sun Microsystems was acquired by the Oracle Corporation in 2010. Oracle has now the steermanship for Java. In 2006 Sun started to make Java available under the GNU General Public License (GPL). Oracle continues this project called OpenJDK.

    Monday 8 May 2017

    Table of 8-bit ASCII Character Codes

    HTTPS://EASYTOJAVALEARNER.BLOGSPOT.COM
    Characters in 8-bit ASCII.
    DecimalOctalHexBinaryValueDescription
    0000000000000 0000NUL"null" character
    0010010010000 0001SOHstart of header
    0020020020000 0010STXstart of text
    0030030030000 0011ETXend of text
    0040040040000 0100EOTend of transmission
    0050050050000 0101ENQenquiry
    0060060060000 0110ACKacknowledgment
    0070070070000 0111BELbell
    0080100080000 1000BSbackspace
    0090110090000 1001HThorizontal tab
    01001200A0000 1010LFline feed
    01101300B0000 1011VTvertical tab
    01201400C0000 1100FFform feed
    01301500D0000 1101CRcarriage return
    01401600E0000 1110SOshift out
    01501700F0000 1111SIshift in
    0160200100001 0000DLEdata link escape
    0170210110001 0001DC1device control 1 (XON)
    0180220120001 0010DC2device control 2
    0190230130001 0011DC3device control 3 (XOFF)
    0200240140001 0100DC4device control 4
    0210250150001 0101NAKnegative acknowledgement
    0220260160001 0110SYNsynchronous idle
    0230270170001 0111ETBend of transmission block
    0240300180001 1000CANcancel
    0250310190001 1001EMend of medium
    02603201A0001 1010SUBsubstitute
    02703301B0001 1011ESCescape
    02803401C0001 1100FSfile separator
    02903501D0001 1101GSgroup separator
    03003601E0001 1110RSrequest to send/record separator
    03103701F0001 1111USunit separator
    0320400200010 0000SPspace
    0330410210010 0001!exclamation mark
    0340420220010 0010"double quote
    0350430230010 0011#number sign
    0360440240010 0100$dollar sign
    0370450250010 0101%percent
    0380460260010 0110&ampersand
    0390470270010 0111'single quote
    0400500280010 1000(left/opening parenthesis
    0410510290010 1001)right/closing parenthesis
    04205202A0010 1010*asterisk
    04305302B0010 1011+plus
    04405402C0010 1100,comma
    04505502D0010 1101-minus or dash
    04605602E0010 1110.dot
    04705702F0010 1111/forward slash
    0480600300011 00000
    0490610310011 00011
    0500620320011 00102
    0510630330011 00113
    0520640340011 01004
    0530650350011 01015
    0540660360011 01106
    0550670370011 01117
    0560700380011 10008
    0570710390011 10019
    05807203A0011 1010:colon
    05907303B0011 1011;semi-colon
    06007403C0011 1100<less than
    06107503D0011 1101=equal sign
    06207603E0011 1110>greater than
    06307703F0011 1111?question mark
    0641000400100 0000@"at" symbol
    0651010410100 0001A
    0661020420100 0010B
    0671030430100 0011C
    0681040440100 0100D
    0691050450100 0101E
    0701060460100 0110F
    0711070470100 0111G
    0721100480100 1000H
    0731110490100 1001I
    07411204A0100 1010J
    07511304B0100 1011K
    07611404C0100 1100L
    07711504D0100 1101M
    07811604E0100 1110N
    07911704F0100 1111O
    0801200500101 0000P
    0811210510101 0001Q
    0821220520101 0010R
    0831230530101 0011S
    0841240540101 0100T
    0851250550101 0101U
    0861260560101 0110V
    0871270570101 0111W
    0881300580101 1000X
    0891310590101 1001Y
    09013205A0101 1010Z
    09113305B0101 1011[left/opening bracket
    09213405C0101 1100\back slash
    09313505D0101 1101]right/closing bracket
    09413605E0101 1110^caret/circumflex
    09513705F0101 1111_underscore
    0961400600110 0000`
    0971410610110 0001a
    0981420620110 0010b
    0991430630110 0011c
    1001440640110 0100d
    1011450650110 0101e
    1021460660110 0110f
    1031470670110 0111g
    1041500680110 1000h
    1051510690110 1001i
    10615206A0110 1010j
    10715306B0110 1011k
    10815406C0110 1100l
    10915506D0110 1101m
    11015606E0110 1110n
    11115706F0110 1111o
    1121600700111 0000p
    1131610710111 0001q
    1141620720111 0010r
    1151630730111 0011s
    1161640740111 0100t
    1171650750111 0101u
    1181660760111 0110v
    1191670770111 0111w
    1201700780111 1000x
    1211710790111 1001y
    12217207A0111 1010z
    12317307B0111 1011{left/opening brace
    12417407C0111 1100|vertical bar
    12517507D0111 1101}right/closing brace
    12617607E0111 1110~tilde
    12717707F0111 1111DELdelete

    test

    Manual Testing

    Popular Posts