#RandomAccessFile
Explore tagged Tumblr posts
jacob-cs · 8 years ago
Link
original source : http://tutorials.jenkov.com/java-io/files.html
Files are a common source or destination of data in Java applications. Therefore this text will give you a brief overview of working with files in Java. It is not the intention to explain every technique in detail here, but rather to provide you with enough knowledge to decide on a file access method. Separate pages will describe each of these methods or classes in more detail, including examples of their usage etc.
Reading Files via Java IO
If you need to read a file from one end to the other you can use a FileInputStream or a FileReaderdepending on whether you want to read the file as binary or textual data. These two classes lets you read a file one byte or character at a time from the start to the end of the file, or read the bytes into an array of byte or char, again from start towards the end of the file. You don't have to read the whole file, but you can only read bytes and chars in the sequence they are stored in the file.
If you need to jump around the file and read only parts of it from here and there, you can use aRandomAccessFile.
If you need to jump around the file and read only parts of it from here and there, you can use aRandomAccessFile.
Writing File via Java IO
If you need to write a file from one end to the other you can use a FileOutputStream or a FileWriterdepending on whether you need to write binary data or characters. You can write a byte or character at a time from the beginning to the end of the file, or write arrays of byte and char. Data is stored sequentially in the file in the order they are written.
If you need to skip around a file and write to it in various places, for instance appending to the end of the file, you can use a RandomAccessFile.
Random Access to Files via Java IO
As I have already mentioned, you can get random access to files with Java IO via the RandomAccessFileclass.
Random access doesn't mean that you read or write from truly random places. It just means that you can skip around the file and read from or write to it at the same time in any way you want. No particular access sequence is enforced. This makes it possible to overwrite parts of an existing file, to append to it, delete from it, and of course read from the file from wherever you need to read from it.
File and Directory Info Access
Sometimes you may need access to information about a file rather than its content. For instance, if you need to know the file size or the file attributes of a file. The same may be true for a directory. For instance, you may want to get a list of all files in a given directory. Both file and directory information is available via the File class.
0 notes
javascript83-blog · 5 years ago
Text
Guidelines for Using Exceptions in Java
Tumblr media
Note: Whitespace has been automatically removed by this site for all the code examples.
You may want to read and adopt the guidelines that help you get the most out of Java's exception handling mechanism. You can write powerful and effective Java code by adopting most, or all, of the things recommended here.
Remember that exception handling provides a way to process synchronous errors such as divisions by zero and out-of-range array indexes. It's not meant for handling asynchronous events such as disk I/O completions and mouse clicks and keystrokes.
When to use Exceptions You may be wondering as to how you actually decide to create and throw an exception. As a rule of thumb, create exception classes for all common exceptions that are likely to occur in multiple classes of an application. In order to deal with simple errors that are likely to occur only in individual methods, try not to create an exception class. You can use an if statement in most cases to trap these types of errors.
Here's a simple example that shows when not to use a try-catch block in your code. The code throws an error when there's an exception of the type NullPointerException.
try {
System.out.println(refvar.toString()};
}
catch (NullPointerException e) {
System.out.println("refVar is null!");
This is pure overkill. You can instead use the much simpler if statement to handle these types of simple errors.
if (refVar!=null)
System.out.println(refVar.toString()};
else
System.out.println("refVar is null");
If your code can perform a simple logic test, as shown here, to handle an error, do so, rather than using an exception object to handle the error.
When you neither catch nor throw exceptions When you call any method that throws a checked exception, you must either throw the exception or catch it. If you decide that you can't handle the exception in the method where it occurs, write a throw statement to send the exception up to the calling method, which must then either handle it with an exception handler, or throw it up to its calling method.
The following set of examples show how you must either catch or throw a checked exception, in order to avoid compiler errors.
The first example shows code that throws an IOException. The statement in the method getFileLength may throw an IO exception when it calls the constructor of the RandomAccessFile class. In addition, the statement that calls the length method of the RandomAccessFile object may also throw an IOException. You thus specify the throws clause in the declaration for the getFileLength method to trap IOException.
public static long getFileLength() throws IOException
{
RandomAccessFile in = new RandomAccessFile("mytext.dat", "r");
long length = in.length();
return length;
}
Our next example shows code for a method that calls the getFileLength method. Since we already know that the getFileLength method call throws an IOException error, our new method must either handle the IO Exception or throw it. Our example here shows how to handle the IOException by catching it with a try statement:
public static int getRecordCount()
{
try
{
long length = getFileLength(); // this may throw an IOException
int recordCount = (int) (length / /RECORD_SIZE);
return recordCount;
}
catch (IOException e) // this will catch the IOException
{
System.out.println("IO Exception!");
return 0;
}
}
The third example shows how a method can call the getFileLength method without catching IOException. Instead, it throws the exception.
public static int getRecordCount() throws IOException
{
long length = getFileLength(); //this may throw an IOException
int recordCount = (int) (length / RECORD_SIZE);
return recordCount;
}
The getRecordCount method here includes a throw clause, which ensures that any IOException is thrown up to the calling method.
Our fourth example shows what happens when you don't catch an exception or throw it.
public static int getRecordCount()
{
long length = getFileLength(); //this may throw an IOException
int recordCount = (int) (length / RECORD_SIZE);
return recordCount;
}
Since your code fails to catch or throw a checked exception, you'll receive a compile error:
MyExceptionTest.java.26: unreported exception java.io.IOException;
must be caught or declared to be thrown
The following is a quick summary of best practices and guidelines that enable you to take advantage of Java's exception handling mechanism, without succumbing to common missteps in the use of exceptions.
Begin Early It is a good idea to incorporate exception handling into your applications from the get go, before you even start programming. That is, you must do this at the design stage, as it gets much harder to do it after implementing your applications.
Don't Ever Ignore an Exception Regardless of whether you're dealing with a checked or an unchecked exception, don't ever ignore the exception. Sometimes, you might see code such as the following:
//Following is an empty catch block
try {
...
} catch (SomeException e) {
}
The empty catch block means that the exception is simply ignored - it's not dealt with. You don't want to do this in your programs. At the minimum, if you must really, really ignore the exception, put a comment explaining why you wanted to ignore the exception. You can use printStackTrace to output a simple error message to tell you there was a problem. If you ignore the exception, because of a condition that you've predicted, it means that the program will run on despite the error. However, you're going to run the risk of a complete program failure down the road when conditions change. If you propagate the exception out, you can ensure that the program fails quickly and captures information that helps you fix the error.
Don't use Exception Handling for every Statement The goal of exception handling is to clarify programs - try not to use a try/catch/finally mechanism for every potential exception generating statement. A simple strategy is to enclose a significant amount of code within the try block and specify multiple catch blocks to account for all possible exceptions. End the whole thing with a single finally block if you need to release any resources held by the program. In any case, avoid placing try/catch/finally around each statement that might throw an exception. Your goal is to use exception handling to remove error processing code from the main program code.
Maintain Failure Atomicity Always strive to ensure that when an object throws an exception, the object continues to remain in a well-defined and usable state. Ideally, even after a method fails due to an exception, the object should be left in the state it was before the method was invoked, When a method can do this, it's said to possess the property of failure atomicity.
You can achieve failure atomicity by using any of the following programming techniques.
Design Immutable Objects The easiest way to achieve failure atomicity is by designing immutable objects. Although when you create an object you can change its contents, occasionally, it's a good idea to create objects whose contents cannot be changed after creation. An object such as this is called an immutable object and its class, an immutable class. A good example is the String class, which is an immutable class. You get automatic failure atomicity when an object is immutable, because the state of an object can't be modified after you create the object.
Check Parameters for Validity before the Operation If you're stuck with mutable objects, the best way to achieve failure atomicity is to perform a check for the validity of parameters before the program commences the modification of an object. The following example shows how you do this:
public Object pop() {
if (size == 0)
throw new EmptyStackException();
Object result = elements[--size];
elements[size] = null; // Eliminate obsolete reference
return result;
}
The initial size check ensures that the method will do two things when it tries to pop an element from an empty stack: it will throw an exception and it will do so while leaving the size field in a consistent state. Otherwise, the attempt to pop the element from an empty stack will leave the size field in a negative state which, of course, is an inconsistent state for the object to be in.
Attempt to Execute the Code before you Modify the Object You can write your programs in a way where the code that is susceptible to a potential exception, is run before any code that modifies an object. A good example would be where you would like to add an element to a TreeMap, wherein the new element must be compared using the TreeMap's ordering. If your code attempts to add an incorrect type element, it will fail when a search for the element in the tree is made, before the tree is modified.
Intercept the Failure Another strategy to achieve failure atomicity is to put in code that intercepts a failure that occurs during an operation, and which rolls back the object's state to what it was before the operation began. This strategy is often adopted when modifying disk based data, that is, data contained in a relational database, for example.
Perform Operations on a Temporary Copy of the Object You can limit state changes made to an object by changing a temporary copy of the object. You replace the contents of the object with the temporary copy once you complete the computational operations. If, for some reason, the computational work (say, a sort) ends up failing, no harm is done to the original object, as you're working with just a copy of the object.
Collect Failure Details If you're troubleshooting an easily reproducible failure, it's no big deal whether you're collecting detailed failure information. When dealing with exceptions that are not easily reproducible, it is critical that your exception's toString method captures sufficient details about the failure - to help diagnose and fix the failure.
When an exception occurs, your details message of an exception should capture the current values of all parameters and values that contributed to the exception. If your error message simply states IndexOutofBoundException, it's only of limited use and may, or may not, help you fix the data problem. If, on the other hand, your detail message for the IndexOutofBoundException contains the lower and upper bounds and the index value, you have something meaningful in your hands with which to proceed towards a fix of the failure condition.
Since the stack trace of the exception always contains the precise file and line number that threw the exception, you don't need a lot of information about the source code in your exception messages. To ensure that your exceptions always contain adequate failure details in their details message, use one of the constructors I explained about earlier in this chapter. It is better to do this than to capture the details within a simple string detail message.
The following example shows how you can use a more helpful constructor than the simple String constructor.
/**
* Construct an IndexOutOfBoundsException.
*
* @param lowerBound the lowest legal index value.
* @param upperBound the highest legal index value plus one.
* @param index the actual index value.
*/
public IndexOutOfBoundsException(int lowerBound, int upperBound,
int index) {
// Generate a detail message that captures the failure
super("Lower bound: " + lowerBound +
", Upper bound: " + upperBound +
", Index: " + index);
// Save failure information for programmatic access
this.lowerBound = lowerBound;
this.upperBound = upperBound;
this.index = index;
}
Top Tip: Provide accessor methods for all exceptions, especially for checked exceptions.
As mentioned earlier, it's sometimes useful to provide accessor methods to capture details regarding exactly why a failure happened. In the case of the example just shown, you can, for example, provide accessor methods for lowerBound, upperBound and index. It's critical that you provide such accessor methods for all accessor methods.My site list to string in java
Use Standard Java Exceptions As discussed earlier in the book, the Java platform offers a built-in set of unchecked exceptions which will take care of most of your exception mechanism setting needs. Make a point to try and use these preexisting exceptions before you run off coding your own custom exceptions. Other programmers are familiar with these preexisting exceptions and, therefore, they can easily understand your code. Also, since you'll be using just a set of basic exception classes and not a whole bunch of custom exceptions, your programs need less time to load.
Here are brief descriptions of the most common standard Java exceptions.
IllegalArgumentException
You throw this exception when a caller passes in an argument with an inappropriate value. For example, a calling program that passes a negative number in a parameter that denotes how many times you repeat an action.
IllegalStateException
This is the exception thrown when an object is illegally invoked because of its state - say, when a calling program tries to use an object before it has been initialized.
NullPointerException
Used when a parameter value is null when it ought not to be.
IndexOutofBoundsException
An exception thrown when a caller passes an out of range value in a parameter representing an index into a sequence.
ConcurrentModificationException
Thrown when an object designed for single thread usage finds that it was, or is, being concurrently modified.
UnsupportedOperationException
Thrown when an object doesn't support a specific operation such as when a program tries to delete an element from an append-only list.
Although in most cases it's quite apparent as to which exception applies to an error condition, sometimes, you may find that more than one exception might be correctly used for an error condition. There aren't any cut and dry rules for the specification of exceptions - as with some other things in Java, handling exceptions is an art as well as a science!
Document All of a Method's Exceptions Spend the necessary time to fully document all exceptions thrown by each method in an application. Declare all checked exceptions individually and use the Javadoc tag @throws to document the conditions under which each of the exceptions can be thrown.
It is critical that you don't fall into the bad habit of declaring that a method throws some super class of multiple exception cases that the method is set up to throw. That means that you never declare a method that can throw the generic exception classes Exception or Throwable! Using generic exceptions might handle the exception all right, but it keeps you from understanding the precise error that caused the exception to be thrown.
Top Tip: Always attempt to document every single exception that can potentially be thrown by each method in a program. 
Take care to document both checked and unchecked exceptions. Since unchecked exceptions normally represent programming errors, documenting them can keep you from avoiding those errors. You can use the same Javadoc tag @Throws to document unchecked exceptions, as is the case for checked exceptions.
If multiple methods in a class can throw the same exception, you may document the exception once in the class's documentation comment. This is much more efficient than documenting the exception separately for each of the methods.
Finally, a useful rule of thumb when handling Java exceptions is to always throw early and catch late!
This finally wraps up our discussion of Java's exception handling mechanisms and how to make the best use of them in your code. Our next topic is the effective use of pre and post conditions in your code within the framework of what's called Java assertions, primarily as a way of testing code before you move it to production.
1 note · View note
freemanjulie · 4 years ago
Text
map framework in Java
There are three primary ways of implementing the map framework in Java:
Hash Map: This JAVA Framework allows the implementation of hash table data structures. Elements in Hash Maps are stored in key/value pairs.
TreeMap: This JAVA framework allows the implementation of tree data structures. It provides accessibility to the Navigable Map interface.
LinkedHashMap: This framework allows the implementation of linked lists and hash tables. It extends to the HashMap class where its entries are stored in a hash table.
Stack, queueing and sorting using JFC: In Java Foundation Classes (JFC), stacks are abstract linear data types with predefined boundaries or capacities. They follow a certain order when adding or deleting elements. In linear data structures, components are organized in a straight line, meaning, if one removes or adds an element, the data structure will decrease or increase respectively. Stacks follow a LIFO (Last In First Out) or (FILO) First In Last Out technique of sorting elements, meaning, the last item is always the first one to be removed.
Graph structures and algorithms
Graphs are non-linear data structures comprising of nodes and edges. Sometimes, the nodes are also called vertices. Edges are simply the arcs or lines that connect nodes within the graph. In Java Assignment Help, graph algorithms are a given set of instructions that connect nodes together. Based on the type of data, an algorithm can be used to identify a specific node or even a path between two nodes. Graphs are important in modeling and solving real-world problems Linear and non-linear searching algorithms. Searching is a common action in business applications. It involves fetching the information stored in data structures like maps, lists, arrays, etc. to help the business in decision-making. In most cases, the search action determines how responsive a given application will be for the end-user. Programs written in Java use several types of search algorithms, the most common being linear and non-linear searching algorithms. The linear algorithm is used to identify elements in an array by looping over other elements of the array. The non-linear algorithm is mostly used with sorted arrays to identify various elements and usually returns the index of the found elements or a negative one if there is no index found.
RandomAccessFile
The Random Access File is a class in Java  And Java Assignment Help used to write and read random access files. Basically, a random access file acts as a relatively large array of bytes. File pointer, a cursor applied to the array is used to perform the read-write operations and this is done by moving the cursor. If the program reaches the end-of-file and the required number of bytes have not been reached, then an EOFException is performed. In Java And JAVA Assignment Help, the Random Access File supports several access modes, which include, the read mode and the read and write mode. To read a byte, one must implement the read () method, and this will read a byte located in a position that is currently directed by the file pointer.
0 notes
freecourses-blog · 6 years ago
Text
Become A Professional Java Developer From Scratch
Tumblr media
Master The Worlds Most Popular Programming Language And Become A Pro Developer From Scratch. Become A Professional Java Developer From Scratch What you’ll learn: 103 LecturesUnderstand variables and perform operations with themCreate Arrays to store dataCreate multidimensional arrays to store dataGet the input from the userCreate and manipulate files on the systemUse text input and output to store dataUse binary input and output to store dataUnderstand Object Orient Programming principals in depthUse abstract classes and interfaces to model your classesHandle exceptionsUse Java GUI API to create user interfaces for your Java programsUse the collections framework to store your dataUse multithreading to make your program execute multiple tasks at the same timeConnect you program to a database, store and fetch dataUse Java servlets to create dynamic web contentUse Java server pages to create dynamic web contentUse Java Server Faces to create dynamic web content Requirements: Eclipse and Netbeans(We will download both in the first video) Become A Professional Java Developer From Scratch Description: Over 4400 Enrolled Students Are Already Learning Java, Enroll Now And Start Learning Today Join me on this fantastic journey where we are going to explore Java from ground up. If you never coded before and want to learn Java this is a perfect course for you. We are going to start from basics so that you will feel comfortable writing your own code. This course assumes no previous experience and takes you from beginner concepts like variables, functions and classes and then goes into more detail while we explore advanced Java concepts. We are also going to learn Object Oriented Programming principles which will help you learn any other programming language after you have mastered Java in this course!! I have also added challenging task for you to complete and test your knowledge which is going to bring you from a complete beginner to an experienced developer comfortable writing any program in Java. You will also benefit from my quick response (I check Udemy forums every day if some student has encountered a problem) and you will also get assistance from the other students taking the course. If you are a complete beginner join now and master the worlds most popular programming language, on the other hand if you are a developer already, then it will not hurt you to add one more powerful programming language at your disposal!! Topics Covered Variables Loops Conditionals Classes Objects Methods Arrays Multidimensional Arrays Inheritance Polymorphism Abstract Classes Interfaces Handling Exceptions Creating Files Text Input / Output Binary Input / Output Java Graphical User Interface Collections Multithreading Java Database Programming Java Servlets Java Server Pages Java Server Faces Enroll Now You Will Not Be Disappointed!! Who this course is for: Complete Beginners Students with programming experience who want to learn Java Who is the target audience? Complete BeginnersStudents with programming experience who want to learn Java Course content of Become A Professional Java Developer From Scratch: Total Lecture:81 How To Study This Course Downloading and setting up our environments Variables Numeric operations and String concatenation Augmented Assignment Operators and Increment and Decrement Operators Getting Input from the user Displaying Current time Assignment The if statement Nested If-else statements Switch statement Logical Operators Using if-else statement to controll the input from the user Conditional Expressions Loops Nested Loops Using loops to controll the user input Assignment Classes Constructors with parameters Methods Static, final and scope of a variable Visibility Modifiers Data encapsulation Passing objects to methods Assignment Introducing arrays Processing arrays For each loop Arrays and methods The Arrays class Multidimensional arrays Assignment Inheritance Super, overriding and overloading The Object class Primitive and Reference variables The equals method The protected modifier and preventing Extending and Overriding Assignment Abstract Classes Interfaces Assignment Exceptions Getting information from exceptions and throwing our own exceptions The finally clause The File class Writing and reading data Reading data from the web Assignment FileInputStream and FileOutputStream DataInputStream and DataOutputStream BufferedInputStream and BufferedOutputStream ObjectInputStream and ObjectOutputStream RandomAccessFile class Assignment JFrame Adding a button to our JFrame Layout Managers Using JPanel as a subcontainer Helper Classes Image Icons Other components Listeners and Inner classes Alternative ways to create listeners Mouse Listeners and Mouse Adapters The Timer class Simple Login App More GUI Components Processing JComboBox and JList JScrollBar and JSlider CardLayout, BoxLayout and Box JTabbedPane Menus Dialogs JColorChooser and JFileChooser Assignment ArrayList and LinkedList Stacks, Vectors, Sets and Maps Note About Collections 6 more sections Become A Professional Java Developer From Scratch course Read the full article
0 notes
batexamin · 6 years ago
Text
Best Java Training Institute in Dubai
Site Galleria offers Best Java Training in Dubai with most experienced professionals. Our Instructors are working in Java and related technologies for many years in MNC's.
CORE JAVA AND ADVANCED JAVA TRAINING
Core Java Training In Dubai, Advanced Java Training In Dubai, Top Java Training Institute In Dubai, Online Java Training In Dubai, Training Institute For Java In Dubai, Java Training With Placement In Dubai
We aware of industry needs and we are offering Java Training in Dubai in more practical way. Our team of Java trainers offers Java in Classroom training, Java Online Training and Java Corporate Training services.
We framed our syllabus to match with the real-world requirements for both beginner level to advanced level. Our training will be handled in either weekday or weekends program depends on participants requirement.
Get Java Training in Dubai with Certified Java Experts. We rated as Best Java Training institute in Dubai with 100% Placement Assistance. We ensure that you will become java Expert from this Java Course.
The programming language, Java, was first introduced by Sun Micro systems in the year 1995. And it hasn’t looked back ever since.
We do offer Fast-Track Java Training in Dubai and One-to-One Java Training in Dubai. Here are the major topics we cover under this Java course Syllabus Core Java & J2EE.
Every topic will be covered in mostly practical way with examples.
Site Galleria located in various places in Dubai. We are the best Training Institute offers certification-oriented Java Training in Dubai. Our participants will be eligible to clear all type of interviews at end of our sessions.
We are building a team of Java trainers and participants for their future help and assistance in subject. Our training will be focused on assisting in placements as well. We have separate HR team professionals who will take care of all your interview needs.
Our Java Training in Dubai Course Fees is very moderate compared to others. We are the only Java training institute who can share video reviews of all our students. We mentioned the course timings and start date as well in below.
If you are fresher looking Java courses in Dubai with placement training or working professional in search of Java certification training in Dubai for the advancement of your Java/J2EE knowledge, then put a full stop on your Google search Java training near me or Java Training in Dubai.
Enroll for demo class at Site Galleria and fulfill your dream of pursuing career in Java/ J2EE development.
We have an excellent track record of creating high-quality Java professionals who are good at solving industry’s challenging & real-time problems by applying skills learned in our Java training institute in Dubai.
The main reason which makes us unique Live training institute for Java Certification Training in Dubai is its curriculum which strengthens fundamental of objects-oriented concepts and algorithm concepts along with Java/J2EE.
Hence most of the students who look for Java training in Dubai prefer our job-oriented training program & placement training.
After completing Java/J2EE training from our institute candidates will be capable to create full fledge Java/ J2EE application. We cover all the major aspect of Java which is required to develop cutting edge applications using the latest version of J2EE, J2SE, and J2ME and various Java development IDEs i.e. Eclipse, NetBeans etc.
5 most popular training course in UAE
Core Java Syllabus in Dubai
Module 1: Introduction
Java Why? What? How? When? Where?
Different Java Versions.
How Java is different from other Technologies
Module 2: Introduction To Java Programming Environment
How to Install & set Path.
A Simple Java Program
Compiling & executing Java Program
Phases of Java Program
Analysis of a Java Program
Understanding Syntax and Semantic Error,
Runtime Exception
Name of a Java Source File
Platform Independency
Java Technology (JDK, JRE, JVM, JIT)
Features of Java
Text Editors
Consoles
Module 3: Fundamentals of Java Programming
Naming convention of Java language
Comments
Statements
Blocks (Static, Non-static/instance)
Identifiers
Keywords
Literals
Primitive Data Types, Range
Reference (User defined) Data type
Variables (Primitive, Reference)
Type Casting, Default Value
Operators
Program/Interview questions
Module 4: Control Structures
Working with Control Structures
Types of Control Structures
Decision Control Structure (if, if-else, if else if, switch –case)
Repetition Control Structure (do –while,while, for)
Program/Interview questions
Module 5: Input Fundamentals And Datatypes In Java
Java program inputs from Keyboard
Methods of Keyboard inputs
Scanner, Buffered Reader
Problem Solving
Java Array
What is Array
Array Declaration in java vs C and C++.
Instantiation of an Array
String vs character array.Accessing Array
Elements, Default Value, for-each loop, varargs
Length of an Array (What is –Array Index Out Of Bounds Exception)
Increasing, Decreasing the Size and Copy of an Array
Multi-Dimensional Arrays
Program/Interview questions
Program/Interview questions Difference between C and C++ with Java
Application Compilation and Run
Interview related Question and Answer
Module 6: Object Oriented Programming (Oops Concepts In Deep)
Procedural Vs Object Oriented Program
Different type of Program Procedural Vs Object Oriented.
Top Down Vs Bottom Up Approach
Introduction to Object Oriented
Abstraction, Encapsulation, Inheritance,
Polymorphism.
Introduction to Classes and Objects
Custom Class Definition
Instance and Static Variables
Different ways to create Object Instance
Instance Variable and it's role in a Class
Constructors, types of Constructor,
Constructor Rule, Constructor Overloading
Static Variable and it's use.
Methods and their behavior.
Constructor vs Methods
Constructors
“this” Keyword
Java Access Modifiers (and Specifiers)
Programming Interview related Question and Answer
Call by value, Call by reference
Module 7: Command-Line Arguments
What is a Command-Line Argument?
Java Application with Command-Line Arguments
Conversion of Command-Line Arguments
Passing Command-Line Arguments
Using methods (Static , Non Static)
Loading...
Module 8: Integrated Development Environment
Using various Editors
Program Compilation, Execution in Editor
Using Eclipse IDE
Project Set Up
Source File Generation
Application Compilation and Run
Module 9: Inner Class
First View of Inner Class
Outer Class Access
Types of Inner Class
Module 10: Inheritance
Complete concepts of Inheritance
Sub-Classes
Object Classes
Constructor Calling Chain
The use of "super" Keyword
The use of “private” keyword inheritance.
Reference Casting
Module 11: Abstract Classes and Inheritance
Introduction to Abstract Methods
Abstract Classes and Interface
Interface as a Type
Interface v/s Abstract Class
Interface Definition
Interface Implementation
Multiple Interfaces' Implementation
Interfaces' Inheritance
How to create object of Interface
Module 12: Polymorphism
Introduction to Polymorphism
Types of Polymorphism
Overloading Methods
Overriding Methods
Hiding Methods
Final Class and Method
Polymorphic Behavior in Java
Benefits of Polymorphism
“Is-A” vs “Has-A”
Association Vs Aggregation
Interview related Question and Answer.
Module 13: Package
Package and Class path and its use
First look into Packages
Benefits of Packages
Package Creation and Use
First look into Class path
Class path Setting
Class Import
Package Import
Role of public, protected, default and private w.r.t package
Namespace Management
Package vs. Header File
Creating and Using the Sub Package
Sources and Class Files Management
Module 14: Using Predefined Package & Other Classes
Java.lang Hierarchy
Object class and using toString(), equals(),hashCode(), clone(), finalize() etc
Using Runtime Class, Process Class to play music, video from Java Program
Primitives and Wrapper Class
Math Class
String, StringBuffer, StringBuilder Class
String Constant Pool
Various usage and methods of String,StringBuffer, StringBuilder
Wrapper Classes
System Class using gc(), exit(), etc.
Module 15: New Concepts In Package
Auto boxing and Auto unboxing
Static import.
Instance of operator.
Enum and its use in Java
Working with jar
Module 16: Garbage Collection
Garbage Collection Introduction
Advantages of Garbage Collection
Garbage Collection Procedure
Java API
Interview related Question and Answer
Module 17: Exception Handling
Introduction to Exceptions
Effects of Exceptions
Exception Handling Mechanism
Try, catch, finally blocks
Rules of Exception Handling
Exception class Hierarchy, Checked &
Unchecked Exception
Throw & throws keyword
Custom Exception Class
Chained Exception.
Resource handling & multiple exception class
Interview related Question and Answer.
Module 18: Multithreading
Introduction
Advantages
Creating a Thread by inheriting from Thread class
Run() and start() method.
Constructor of Thread Class
Various Method of Thread Class
Runnable Interface Implementation
Thread Group
Thread States and Priorities
Synchronization method, block
Class & Object Level Lock
Deadlock & its Prevention
Inter thread Synchronization
Life Cycle of Thread
Deprecated methods : stop(), suspend(),resume(), etc
Interview related Question and Answer
Module 19: Input and Output Streams
Java I/O Stream
I/O Stream - Introduction
Types of Streams
Stream Class Hierarchy
Using File Class
Copy and Paste the content of a file
Byte Streams vs Character Streams
Text File vs Binary File
Character Reading from Keyboard by Input Stream Reader
Reading a Line/String from Keyboard by Buffered Reader
Standard I/O Streams Using Data Streams to read/write
primitive data
PrintStream vs PrintWriter Using StreamTokenizer and RandomAccessFile
Interview related Question and Answer
Module 20: Serialization
Introduction to Serialization
Using Object Streams to read/write object
Transient Keyword
Serialization Process
Deserialization Process
Interview related Question and Answer
Module 21: Collection Framework
Generics(Templates)
What is generic
Creating User defined Generic classes
The java.util package
Collection
What is Collection Framework
List, Set & Map interfaces
Using Vector, Array List, Stack,
Linked List, etc.
Using Collections class for sorting
Using Hashtable, Hash Map, Tree Map,
SortedMap, LinkedHashMap etc.
Iterator, Enumerator.
Using Queue, Deque, SortedQue, etc.
Using HashSet, TreeSet, LinkedHashSet etc
Using Random class
Using Properties in a Java Program
Using user defined class for DataStructure
Using Date and Formatting Date class.
Interview related Question and Answer
Module 22: Advanced Java Syllabus
Module 1: JDBC
Introduction to JDBC
Databases and Drivers
Types of Driver
Loading a driver class file
Establishing the Connection to different
Database with different Driver
Executing SQL queries by ResultSet, Statements , Prepared Statment interface.
Using Callable Statement
Transaction Management & Batch Update
Programs/Interview related Question and Answer
Module 2: JSP
· Basics Of Jsp
Life cycle of JSPJSP APIJSP in Eclipse and other IDE'sPrograms/Interview related Question and Answer.
· Scripting Elements
scriptlet tagexpression tagdeclaration tagPrograms/Interview related Question and Answer.
· Implicit Objects
outrequestresponseconfigapplicationsessionpageContextpageexceptionPrograms/Interview related Question and Answer.
· Directive Elements
page directiveinclude directivetaglib directivePrograms/Interview related Question and Answer.
· Exception Handling
· Action Elements
jsp:forwardjsp:includeBean classjsp:useBeanjsp:setProperty & jsp:getPropertyDisplaying applet in JSP
· Expression Language
What is expression and how to use itDefine expression and use over the service flowThe way to be achieve same in JSP
· Mvc In Jsp
MVC patternWorking flow implementation of MVCCRUD operation using MVCDesign a real time web application using MVC
· JSTL
Discussion on the tag libraryHow to implement and use
· Custom Tags
Custom Tag : What and Why?Custom Tag API?Custom Tag ExampleAttributesIterationCustom URI
Module 3: Servlet
Basics of Servlet
Servlet: What and Why?
Basics of Web
Servlet API
Servlet Interface
GenericServlet
HttpServlet
Servlet Life Cycle
Working with Apache Tomcat Server
Steps to create a servlet in Tomcat
How servlet works?
servlet in Myeclipse
servlet in Eclipse
servlet in Netbeans
· Servlet request
Servlet Request methodsRegistration example with DB
· Servlet Collaboration
Request Dispatchersend Redirect
· Servlet Configure
Servlet Configure methodsServlet Configure example
· Servlet Context
Servlet Context methodsServlet Context example
· Session Tracking
CookiesHidden Form FieldURL RewritingHttpSession
Loading...
Module 4: Concurrent and implementation of collection
Implemenation of ArrayList
Implemenation of LinkedList
Implemenation of HashMap
Implementation of Queue/PriorityQueue/Deque
Module 5: Advanced Multi-Threading
Implemenation of Executor pool service and working mechanism with real time
Big file(Single , multiple ) processing using multiple thread
Implemenation to achieve thread class and runnable interface
Module 6: Javamail
Sending Email
Sending email through Gmail server
Receiving Email
Sending HTML content
Module 7: Design Pattern
Singleton
DAO
DTO
MVC
Front Controller
Factory Method
Abstract
etc
Module 8: Junit
JUnit: What and Why?
Annotations used in JUnit
Assert class
Test Cases
Module 9: Maven
Maven: What and Why?
Ant Vs Maven
How to install Maven?
Maven Repository
Understanding pom.xml
Maven Example
Maven Web App Example
Maven using Eclipse
Why choose for Site Galleria?
Now, while opting for Java training in Dubai, the foremost thing that strikes our mind is which institute can provide us the top-most services at the most affordable rates?
Unlike other institutions that charge an expensive fee, we at Site Galleria Dubai aims to satisfy our candidates by providing them with easy read yet latest training materials, wonderful and comfortable learning environment.
These benefits have what made us stand out of our competitors. In order to aid you to encounter the entire corporate requirements, we’ve come up with a wide variety of Java training in Dubai.
What’s more? The syllabus and course material we are offering are generally prepared by the professional trainers that possess adequate experience in IT companies. Still aren’t sure if our institution is the right fit for your training?
Hit our organization to ascertain the catalog of companies our candidates are recruited in. The Java training at Site Galleria offers theoretical based study emphasized with hands-on sessions. Seeking our custom as well as standard courses, you can turn out to be an expert application developer from a novice.
Related Search Term
Java Training in Dubai
Which is the best institute for Java training in Dubai?
Core and Advanced Java Training Institute in Dubai
Java Training Reviews
Aasif
I have Completed My Java Course with Site Galleria in April. It was great experience doing the course over here. Perfect environment to learn technology and implement own ideas as a fresher. Trainers will explain every scenario with real time examples. The placement team is awesome they helped me a lot in placement. the best thing in Site Galleria is Simultaneously we can attend the drives if we are eligible. I got the Placement in MNC, Thanks Site Galleria team for support.
Aaleyah
My Journey with SITE GALLERIA for Technology Training is awesome, Good infrastructure and Lab access. The teaching Faculty is Very Skilled and Experienced, They are very Friendly Nature always supports the students and clarifies the doubts as per your requirement. Even they guided me for how to crack the interview. I got placement through SITE GALLERIA drive. Thanks SITE GALLERIA
Aasma
After completion of My B.E. I joined in SITE GALLERIA for JAVA Training. The trainers are awesome, they will teach real time scenarios with examples and they are very supportive even Placements team will help in Interviews. They conduct weekly drives. I got placement in MNC through SITE GALLERIA. Thanks SITE GALLERIA
Parvez
I have joined SITE GALLERIA for Technology for Software testing course. And to my surprise, I found the course and environment both more interesting with such amazingly skilled trainers. Perhaps this is one of the best testing training institution in Dubai offering quality testing tools course over both manual and automation that I can recommend for people who wish to have testing certifications. it is just worth the money.
Falak
Hope my review will helps someone. If you are looking for java training with placement then SITE GALLERIA is one of the institutes in Dubai, facilities are good. They provided free material and they will conduct mock interviews before drives, trainers are good they are very interactive and supportive to students. after course completion I attended 2 drives conducted by SITE GALLERIA. I placed in MNC as a java developer. Thanks SITE GALLERIA for support.
Heena
Nice classes for Java. Trainers are very knowledgeable and help a lot to clear our doubts. Theory and practical’s wise are good. Your practical’s concepts will get clear. Good hands on real devices. Nice environment experience for study. also provides placement after training. Even got practice sessions for how to crack the interview. Overall it was good
Nasser
SITE GALLERIA is excellent institute for java training. I completed java course in SITE GALLERIA. After completing course weekly they conduct drives. SITE GALLERIA Trainers and Counselors helped me a lot in every moment of training and interviews .Thanks SITE GALLERIA for Support.
Noor
I have done my software testing training from SITE GALLERIA and I really want to tell you that the environment and trainers are awesome. They provide experienced faculties who clear every doubts of every students and provide 100% placement also. it was a superb experience.
Na’imah
This is best Training institute in Dubai for Java & Software Testing for Fresher and they provide placement to each student. I have done my testing course in SITE GALLERIA and finally got placed in good company. Thanks to all the SITE GALLERIA Team members and facilities.!
Sadiya
The initial rounds of interview took place at SITE GALLERIA FOR JAVA & TESTING. SITE GALLERIA is among the top finishing schools with their rich curriculum content. The infrastructure is great & helps to deliver hands on experience for students which help them learn better. The trainers have vast knowledge which are passed onto the students which help them acquire skills as required by companies visiting for recruitment. The journey through SITE GALLERIA was great.
Faisal
SITE GALLERIA for Java & Testing is the best place to learn Java programming language. Can learn manual testing also. It is one of the best coaching institutions for Java in Dubai.
Sana
The learning experience was excellent and and the knowledge gained from that course met industry standards which helped me to clear the rounds with confidence.
Noushin
Very good teaching staff and have experienced teachers and excellent student friendly environment, Great place to learn basic java course. I recommend to everyone to join and start your learning process now. Thanks Site Galleria team to giving everyone such exposure.
Fayd
I would like to thank SITE GALLERIA for the kind of training they provided so that I got placed in a reputed company. Training at SITE GALLERIA was a game changing experience for me. My knowledge in JAVA enhanced to great extent. I revised all the concepts daily and practiced aptitude and coding daily. At SITE GALLERIA we get numerous opportunities as many reputed companies visit for placement drive.
Rahma
The trainers will take care of every student from the point he/she entered the SITE GALLERIA till they got placed in a company. The quality of trainers and the infrastructure they provided is the best part of SITE GALLERIA. They provide materials, daily mock tests, weekly mock interviews, labs which will help you a lot in chasing your dream job.
Wajid
SITE GALLERIA is the best institute in Dubai to teach java and testing. Firstly, I would like to thank SITE GALLERIA for encouragements and placements given to us. I don't think there is any other institute which gives u with maximum placements. Thank you, SITE GALLERIA for teaching us JAVA and Testing in students’ friendly manner and placing us. The grooming sessions conducted for the respective companies is very useful. Thanks a lot SITE GALLERIA!
Shaheen
I firstly thank SITE GALLERIA for providing me a opportunity to get a chance to work in mnc when I initially heard about SITE GALLERIA I thought it is also a institute like all other common institute but I was proved wrong by this faculty by their way of teaching, i can tell that irrespective of your branch if you want to get placed in IT industry with good programming skill join SITE GALLERIA, Take this step and you would never get hesitated in your life for this. Thank You SITE GALLERIA
Yaseen
SITE GALLERIA has groomed to a programmer. That's what SITE GALLERIA is all about. They are best among all the java and testing training institute. The thing I liked about SITE GALLERIA is the way of teaching. Trainers here teach each and every concept using simple language and examples so that a student from non CS-IS branch can also grasp hold of the concept. The grooming classes they provide before every drive is very much helpful.
Yasmin
I joined SITE GALLERIA to learn Java and to get placed in a good company which turned out to be the best decision I have ever made. I am very much impressed by the quality with which the concepts are taught. They not only provide opportunities, but also prepare us by providing grooming sessions which were really helpful in getting the job. Thank you SITE GALLERIA for supporting me.
Yasir
I would like to thank SITE GALLERIA for the quality of education they have provided. SITE GALLERIA is the best finishing school and the best place to gain maximum knowledge. They provide the best training in all the aspects such that every individual can step into an IT industry with huge amount of knowledge on the domain.
Java Training Locations in Dubai
Site Galleria branches in Dubai are listed above. And most popular locations where students / professionals are lining up to get trained with us.
0 notes
javatutorialcorner · 8 years ago
Text
Design Patterns - Adapter Pattern
Adapter Pattern
Also known as Wrapper.
Definition
The Adapter pattern is used to translate the interface of one class into another interface. This means that we can make classes work together that couldn't otherwise because of incompatible interfaces. A class adapter uses multiple inheritance (by extending one class and/or implementing one or more classes) to adapt one interface to another. An object adapter relies on object aggregation.
Where to use
•When you want to use an existing class, and its interface does not match the one you need. •When you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces. •When you want to increase transparency of classes. •When you want to make a pluggable kit.
Benefits
•Highly class reusable. •Introduces only one object
Drawbacks/consequences
When using Java, Target must be an interface.
Adapter Pattern - Class Diagram
In the class-diagram above: •A Client class expects a certain interface (called the Target interface) •An available interface doesn't match the Target interface •An Adapter class bridges the gap between the Target interface and the available interface •The available interface is called the Adaptee
Adapter Pattern Example
public interface FileManager { public String open(String s); public String close(); public String read(int pos, int amount, byte[] data); public String write(int pos, int amount, byte[] data); } import java.util.*; import java.io.*; public class FileManagerUtil { private RandomAccessFile f; public boolean openFile(String fileName) { System.out.println("Opening file: "+fileName); boolean success=true; return success; } public boolean closeFile() { System.out.println("Closing file"); boolean success=true; return success; } public boolean writeToFile(String d, long pos, long amount) { System.out.print("Writing "+amount+ " chars from string: "+d); System.out.println(" to pos: "+pos+" in file"); boolean success=true; return success; } public String readFromFile(long pos, long amount) { System.out.print("Reading "+amount+ " chars from pos: "+pos+" in file"); return new String("dynamite"); } } public class FileManagerImpl extends FileManagerUtil implements FileManager { public String close() { return new Boolean(closeFile()).toString(); } public String open(String s) { return new Boolean(openFile(s)).toString(); } public String read(int pos, int amount, byte[] data) { return readFromFile(pos, amount); } public String write(int pos, int amount, byte[] data) { boolean tmp= writeToFile(new String(data), pos, amount); return String.valueOf(tmp); } } public class FileManagerClient { public static void main(String[] args) { FileManager f = null; String dummyData = "dynamite"; f = new FileManagerImpl(); System.out.println("Using filemanager: "+ f.getClass().toString()); f.open("dummyfile.dat"); f.write(0, dummyData.length(), dummyData.getBytes()); String test = f.read(0,dummyData.length(), dummyData.getBytes()); System.out.println("Data written and read: "+test); f.close(); } }
Imagine you need to develop a simple file manager to handle text documents. There is an existing resource that already handles this, but by some reason you are forced to a specific interface for your file manager. By using a class adapter we can use the forced interface and still reuse the existing functionality. In the class diagram below the interface FileManager is the target (desired interface). FileManagerUtil is the existing utility class that we would like to adapt to FileManager interface. We do the actual adaptation in the class FileManagerImpl, this class uses the desired interface and the existing functionality through inheritance, i.e. a class adapter. When FileManagerClient is executed the result is:
c:>Opening file: dummyfile.dat c:>Writing 8 chars from string: dynamite to pos: 0 in file c:>Reading 8 chars from pos: 0 in fileData written and read: dynamite c:>Closing file
Usage example
The Java API uses the Adapter pattern, WindowAdapter, ComponentAdapter, ContainerAdapter, FocusAdapter, KeyAdapter, MouseAdapter, MouseMotionAdapter.
from Java Tutorials Corner http://ift.tt/2eJnTNc via IFTTT
0 notes
ramram43210 · 8 years ago
Video
youtube
Java Tutorial : Java IO (Java RandomAccessFile - V1)
0 notes
slsathish1306 · 8 years ago
Text
Java Q/A Part XV
Java Q/A Part XV
What is the purpose of the enableEvents() method? The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.
What is the difference between the File and RandomAccessFile classes?
View On WordPress
0 notes