



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
It's a Summer Training Report on Core Java In Detail.
Typology: Assignments
Limited-time offer
Uploaded on 01/13/2021
4.8
(4)3 documents
1 / 43
This page cannot be seen from the preview
Don't miss anything!
On special offer
Internal Examiner External Examiner
Name : Pranshi Chaurasia
Udemy Community, In these times of challenge and change, Udemy’s mission to improve lives through learning is more vital than ever. We remain committed to providing people around the world affordable access to the skills needed to meet the demands of our changing world. Since Udemy’s founding over a decade ago, we’ve enabled our expert instructor community to create, host, and share over 15,000 free courses with students around the world. We’re grateful every day for the thousands of Udemy instructors helping millions of people find purpose and passion. Today, we released the Udemy Free Resource Center , a place where individual learners can find a curated collection of over 150 free Udemy courses to help people everywhere face new challenges and opportunities and do whatever comes next. In addition, organizational leaders can access free content and register for virtual events to help them lead their organizations through change. In this resource center, learners will find courses to help them adapt to working from home, search for a job, stay active and maintain balance while spending time at home. As the world changes and our course catalog evolves, we’ll add new courses and more resources for leaders on an ongoing basis. Gregg Coccari Udemy CEO
Australia Belgium Djibouti Germany Hong Kong India Indonesia Japan Mexico Netherlands Oman Palestine Philippines Poland Saudi Arabia Singapore Spain United Arab Emirates United Kingdom
Annual Subscription On-demand access to 3,000+ courses Private Logo & URL Mobile app for iOS and Android Create user groups Assign courses to users
User adoption and enrollment Individual user engagement Course analytics Overall user activity Course completion
With the invention of microprocessors, the world is scientifically developed with sophisticated equipments, systems, and devices. Microprocessors are used in computers, televisions, and fax machines. Even the hand-held devices such as pagers, PDAs (Personal Digital Assistant), and cell phones make use of microprocessors. All these electronic devices are helpful because of their communication capabilities. With the increasing capabilities and decreasing cost of information processing and networking technologies, the network is growing rapidly for transmitting information through electronic systems. Internet is the network of networks between different types of computers located at different places to transmit information. Information can reach to any place in the world quickly at a cheaper rate through the Internet. Thus, the Internet has made the world a global village for information exchange. The emerging infrastructure of electronic devices and interconnected computer networks create an environment that presents new challenges to software industries. for this emerging computing environment, Java process to be a well – suited programming language. it is found suitable for networked environments involving a great variety of computer and devices. Java has many characteristics that have contributed to its popularity: Platform independence - Many languages are compatible with only one platform. Java was specifically designed so that it would run on any computer, regardless if it was running Windows, Linux, Mac, Unix or any of the other operating systems. Simple and easy to use - Java's creators tried to design it so code could be written efficiently and easily. Multi-functional - Java can produce many applications from command- line programs to applets to Swing windows (basically, sophisticated graphical user interfaces). Java does have some drawbacks. Since it has automated garbage collection, it can tend to use more memory than other similar languages. There are often implementation differences on different platforms, which have led to Java being described as a "write once, test everywhere" system. Lastly, since it uses an abstract "virtual machine", a generic Java program doesn't have access to the Native API's on a system directly. None of these issues are fatal, but it can mean that Java isn't an appropriate choice for a particular piece of software.
One thing that distinguished Java from some other languages is its ability to run the same compiled code across multiple operating systems.In other languages, the source code (code that is written by the programmer), is compiled by a compiler into an executable file. This file is in machine language, and is intended for a single operating system/processor combination, so the programmer would have to re-compile the program seperately for each new operating system/processor combination.Java is different in that it does not compile the code directly into machine language code. Compilation creates bytecode out of the source code. Bytecode generally looks something like this: a7 f4 73 5a 1b 92 7d When the code is run by the user, it is processed by something called the Java Virtual Machine (JVM). The JVM is essentially an interpreter for the bytecode. It goes through the bytecode and runs it. There are different versions of the JVM that are compatible with each OS and can run the same code. There is virtually no difference for the end-user, but this makes it a lot easier for programmers doing software development.
In 2006 Sun started to make Java available under the GNU General Public License (GPL). Oracle continues this project called OpenJDK.
The Java virtual machine (JVM) is a software implementation of a computer that executes programs like a real machine. The Java virtual machine is written specifically for a specific operating system, e.g. for Linux a special implementation is required as well as for Windows.
The Java virtual machine interprets this bytecode and executes the Java program.
To download the JDK, go to http://www.oracle.com/technetwork/java/javase/downloads/index.html. Click on "JDK with NetBeans Bundle". Follow the instructions for downloading the JDK installation file.
If you are running Windows, simply run the executable file and follow the installation instructions.
For Linux and Unix, download the "jdk1 6.0" for Linux systems. Save the downloaded file in any drive. Once you have saved the file, extract it to a place that you can remember, by using Terminal or by double clicking on the file. When you have finished extracting the file, copy the JDK 1.6.0 folder and paste it in the user/local(To paste to the user/local directory, you have to be in root) so that every user can use the java files. You can delete the downloaded zip file so that it doesn't take up space on your drive.
The latest available JDK is automatically installed by the operating system. Because Java for Macintosh is developed and maintained by Apple, in coordination with Sun, the current version on the Macintosh may not be the current version that is available
The JDK comes in three editions. Java Standard Edition (JSE) – This version is the basic platform for Java. The course will focus on this edition. Java Enterprise Edition (JEE) – This edition is mainly for developing and running distributed multitier architecture Java applications, based largely on modular software components running on an application server. We will not be covering this version in the course.
Java Micro Edition (JME) – This edition is primarily for developing programs to run on consumer applicances, such as PDAs and cell phones.
Before writing code, it is recommended that you set the Path variable on your system so you can compile your code more easily.
From the Control Panel, double click "System" (System and Maintenance in Vista) For Windows 7,10 or Vista, click on "System," "Advanced System Settings" on the left, and then on "Environment Variables." For XP and 2000, click on the "Advanced" tab and click on "Environment Variables" For NT, click on the "Environment" tab. Select the Path variable and click "Edit" Add the path to the bin directory of where Java is installed on your hard drive. It should probably be: C:\Program Files\Java\jdk1.6.0_20\bin unless you changed it during installation. Click OK
One way to set your path in Linux/Unix is to add a path export to your bash profile. In order to do this, first open your bash profile in a text editor. For example, pico ~/.bash_profile Then add this line: export PATH=$PATH:/usr/local/jdk/bin Note that the path to the java directory "/usr/local/jdk/bin" may be different on your machine. Restart your shell.
While the garbage collector releases the programmer from the need to explicitly manage memory the programmer still need to ensure that he does not keep unneeded object references otherwise the garbage collector cannot release the associated memory.Keeping unneeded object references are typically called memory leaks.
The classpath defines where the Java compiler and Java runtime look for .class files to load. This instructions can be used in the Java program. For example if you want to use an external Java library you have to add this library to your classpath to use it in your program.
The following Java program is developed under Linux using a text editor and the command line. The process on other operating system should be similar and but is not covered in this description. Select or create a new directory which will be used for your Java development. In this description the path \home\vogella\javastarter is used. On Microsoft Windows your might want to use c:\temp\javastarter. This path is called javadir in the following description. Open a text editor which supports plain text, e.g. gedit under Linux or Notepad under Windows and write the following source code. Save the source code in your javadir directory with the HelloWorld.java filename. The name of a Java source file must always equals the class name (within the source code) and end with the .java extension. In this example the filename must be HelloWorld.java because the class is called HelloWorld.
Switch to the javadir directory with the command cd javadir, for example in the above example via the cd\home\vogella\javastarter command. Use the ls command (dir under Microsoft Windows) to verify that the source file is in the
directory. Compile your Java source file into a class file with the following command. javac HelloWorld.java Afterwards list again the content of the directory with the ls or dir command. The directory contains now a file "HelloWorld.class". If you see this file you have successfully compiled your first Java source code into bytecode. You can now start your compiled Java program. Ensure that you are still in the jardir directory and enter the following command to start your Java program. java HelloWorld The system should write "Hello World" on the command line.
You can use the classpath to run the program from another place in your directory. Switch to the command line, e.g. under Windows Start-> Run -> cmd. Switch to any directory you want. Type: java HelloWorld If you are not in the directory in which the compiled class is stored then the system should result an error message Exception in thread "main" java.lang.NoClassDefFoundError: test/TestClass To use the class type the following command. Replace "mydirectory" with the directory which contains the test directory. You should again see the "HelloWorld" output. java -classpath "mydirectory" HelloWorld Java basic terms
It is important to understand the base terminology of Java in terms of packages , classes and objects. This section gives an overview of these terms.
A class can be derived from another class. In this case this class is called a subclass. Another common phrase is that a class extends another class. The class from which the subclass is derived is called a superclass. Inheritance allows a class to inherit the behavior and data definitions of another class. The following codes demonstrates how a class can extend another class. In Java a class can extend a maximum of one class. package com.vogella.javaintro.base; class MyBaseClass { void hello(){ System.out.println("Hello from MyBaseClass"); }} package com.vogella.javaintro.base; class MyExtensionClass extends MyBaseClass { }
If a class extends another class it inherits the methods from its superclass. If it wants to change these methods it can override these methods. To override a method you use the same method signature in the source code of the subclass. To indicate to the reader of the source code and the Java compiler that you have the intention to override a method you can use the @override annotation. The following code demonstrates how you can override a method from a superclass. package com.vogella.javaintro.base; class MyBaseClass { void hello(){ System.out.println("Hello from MyBaseClass"); } } package com.vogella.javaintro.base; class MyExtensionClass2 extends MyBaseClass { }
Every object in Java implicitly extends the Object class. The class defines the following methods for every Java object: equals(o1) allows to check if the current object is equal to o
getClass() returns the class of the object hashCode() returns an identifier of the current object toString() Give a string representation of the current object
Variables allow the Java program to store values during the runtime of the program. A variable can either be a primitive variable or a reference variable. A primitive variable contains value while the reference variable contains a reference (pointer) to the object. Hence if you compare two reference variables, you compare if both point to the same object. To compare objects use the object1.equals(object2) method call.
Instance variable is associated with an instance of the class (also called object). Access works over these objects. Instance variables can have any access control and can be marked final or transient. Instance variables marked as final can not be changed after assigned to a value.
Local (stack) variable declarations cannot have access modifiers. final is the only modifier available to local variables. This modifier defines that the variable can not be changed after first assignment. Local variables do not get default values, so they must be initialized before use.
A method is a block of code with parameters and a return value. It can be called on the object. package com.vogella.javaintro.base; public class MyMethodExample { void tester(String s) { System.out.println("Hello World"); }