Advanced Java coaching

Advanced Java coaching

Trending Questions and Lessons

Follow 4,706 Followers

Ask a Question

Feed

All

All

Lessons

Discussion

Answered on 01/09/2017 Advanced Java coaching

I am having almost 10 years of work experience in Java. I am looking for any part time trainer job. How to proceed?

Surabhi Technologies

See if you are interested in coding you can take up certification course of that if not the option to land in IT is to do technical writing course.
Answers 1 Comments 1
Dislike Bookmark

Lesson Posted on 24/06/2017 Advanced PHP Training Advanced Java coaching Laws of Motion +1 IT Courses/Angular.JS less

EFFECTIVE TASKS & RESPONSIBILITIES DELEGATION

Rohit Raj Verma

I have 8+ years of experience in the area of web development and application programming. I have worked...

Do you feel your business relies too much on you? In working with business owners, there are a couple of tools we introduce to productively shift the workload and responsibility across the organization. If you use just one of these tools, we guarantee you will see a noticeable improvement in your current... read more

Do you feel your business relies too much on you?

In working with business owners, there are a couple of tools we introduce to productively shift the workload and responsibility across the organization. If you use just one of these tools, we guarantee you will see a noticeable improvement in your current working situation.

First, document what you do!

The first tool or practice we typically prescribe is to ask you to document everything you do for 10 business days. In other words, we provide a form you fill in that indicates when you begin an activity, when you end it, what the activity is and what “category” it fits into. In TouchStone, go to the “Task Delegation & Work Management” inside of the “Guiding” the Business Process Library.

Before you start, be sure to select categories you’d like to track. For instance, if you suspect you’re spending too much time on administrative work, set up an Administrative category. Alternately, you might like to track the amount of time you devote to Sales, Marketing, Operations or Strategic Work.

I used this tool many years ago when a partner of mine suggested I might be spending too much time acting as the board president of my son’s private school and not enough time on our business. When I tracked my time, using Company Work as one category and School Work as another, I was astonished to find that the amount of time I worked as the school’s board president almost constituted a second job. I made adjustments and had more time to devote to my business.

Next, ask if it can be delegated!

Another worksheet we use asks you to document every activity and then note whether that activity could be delegated if you had:

  • someone to delegate it to and/or
  • a system that would support the activity’s productive delegation.

In TouchStone, go to the “Task Delegation & Work Management” inside of the “Guiding” the Business Process Library.

Pretty quickly you’ll find activities that you can delegate to others in your organization with low risk to your company and your customers.

Then, when you take the practice a step further, you may find other areas that you thought you had to do that could be conducted by another member of your team. For example, several years ago I worked with the head of an insurance agency who insisted that “sorting the mail” could not be delegated. I was surprised to think that this leader of a fairly large agency took the time to go to the post office box, get the mail and sort through it every day.

What we discovered was that sorting the mail wasn’t the issue but that he was reluctant to let go of addressing some of the important client communications that came through the mail, and rightly so. So, we developed a simple system that guided his office manager in getting the mail, throwing out junk mail, delivering client communications to the business owner and delivering accounts payables and receivables to the head of finance. It sounds so simple, but until he was able to think through what he was doing, examine the mail “process”, and discover how much time each week he spent processing the mail, he was unwilling to delegate that task to another employee.

Try it for yourself

Sorting the mail might sound like an obvious task to delegate, but you’d be surprised to see what activities business owners and top management hold on to, including you. As you work through this exercise – and even if you only do it for a day or two – you’ll experience many insights that free you up to re-distribute work and have more time to devote to growing and developing your business.

read less
Comments
Dislike Bookmark

Lesson Posted on 24/06/2017 Advanced PHP Training IT Courses/MySQL Advanced Java coaching +4 IT Courses/Angular.JS IT Courses/Node.JS IT Courses/Programming Languages/PHP IT Courses/Programming Languages/PHP /Php MySQL less

Git Branching: Basic Branching And Merging

Rohit Raj Verma

I have 8+ years of experience in the area of web development and application programming. I have worked...

Basic Branching and Merging: Let’s go through a simple example of branching and merging with a workflow that you might use in the real world. You’ll follow these steps: Do work on a web site. Create a branch for a new story you’re working on. Do some work in that branch. At... read more

Basic Branching and Merging:

Let’s go through a simple example of branching and merging with a workflow that you might use in the real world. You’ll follow these steps:

  1. Do work on a web site.
  2. Create a branch for a new story you’re working on.
  3. Do some work in that branch.

At this stage, you’ll receive a call that another issue is critical and you need a hotfix. You’ll do the following:

  1. Switch back to your production branch.
  2. Create a branch to add the hotfix.
  3. After it’s tested, merge the hotfix branch, and push to production.
  4. Switch back to your original story and continue working.

Basic Branching

First, let’s say you’re working on your project and have a couple of commits already (see Figure 3-10).


Figure 3-10. A short and simple commit history.

You’ve decided that you’re going to work on issue #53 in whatever issue-tracking system your company uses. To be clear, Git isn’t tied into any particular issue-tracking system; but because issue #53 is a focused topic that you want to work on, you’ll create a new branch in which to work. To create a branch and switch to it at the same time, you can run the git checkout command with the -b switch:

$ git checkout -b iss53
Switched to a new branch 'iss53'

This is shorthand for:

$ git branch iss53
$ git checkout iss53

Figure 3-11 illustrates the result.


Figure 3-11. Creating a new branch pointer.

You work on your web site and do some commits. Doing so moves the iss53 branch forward, because you have it checked out (that is, your HEAD is pointing to it; see Figure 3-12):

$ vim index.html
$ git commit -a -m 'add a new footer [issue 53]'


Figure 3-12. The iss53 branch has moved forward with your work.

Now you get the call that there is an issue with the web site, and you need to fix it immediately. With Git, you don’t have to deploy your fix along with the iss53 changes you’ve made, and you don’t have to put a lot of effort into reverting those changes before you can work on applying your fix to what is in production. All you have to do is switch back to your master branch.

However, before you do that, note that if your working directory or staging area has uncommitted changes that conflict with the branch you’re checking out, Git won’t let you switch branches. It’s best to have a clean working state when you switch branches. There are ways to get around this (namely, stashing and commit amending) that we’ll cover later. For now, you’ve committed all your changes, so you can switch back to your master branch:

$ git checkout master
Switched to branch 'master'

At this point, your project working directory is exactly the way it was before you started working on issue #53, and you can concentrate on your hotfix. This is an important point to remember: Git resets your working directory to look like the snapshot of the commit that the branch you check out points to. It adds, removes, and modifies files automatically to make sure your working copy is what the branch looked like on your last commit to it.

Next, you have a hotfix to make. Let’s create a hotfix branch on which to work until it’s completed (see Figure 3-13):

$ git checkout -b hotfix
Switched to a new branch 'hotfix'
$ vim index.html
$ git commit -a -m 'fix the broken email address'
[hotfix 3a0874c] fix the broken email address
 1 files changed, 1 deletion(-)


Figure 3-13. hotfix branch based back at your master branch point.

You can run your tests, make sure the hotfix is what you want, and merge it back into your master branch to deploy to production. You do this with the git merge command:

$ git checkout master
$ git merge hotfix
Updating f42c576..3a0874c
Fast-forward
 README | 1 -
 1 file changed, 1 deletion(-)

You’ll notice the phrase “Fast-forward” in that merge. Because the commit pointed to by the branch you merged in was directly upstream of the commit you’re on, Git moves the pointer forward. To phrase that another way, when you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward because there is no divergent work to merge together — this is called a “fast forward”.

Your change is now in the snapshot of the commit pointed to by the master branch, and you can deploy your change (see Figure 3-14).


Figure 3-14. Your master branch points to the same place as your hotfix branch after the merge.

After your super-important fix is deployed, you’re ready to switch back to the work you were doing before you were interrupted. However, first you’ll delete the hotfix branch, because you no longer need it — the master branch points at the same place. You can delete it with the -d option to git branch:

$ git branch -d hotfix
Deleted branch hotfix (was 3a0874c).

Now you can switch back to your work-in-progress branch on issue #53 and continue working on it (see Figure 3-15):

$ git checkout iss53
Switched to branch 'iss53'
$ vim index.html
$ git commit -a -m 'finish the new footer [issue 53]'
[iss53 ad82d7a] finish the new footer [issue 53]
 1 file changed, 1 insertion(+)


Figure 3-15. Your iss53 branch can move forward independently.

It’s worth noting here that the work you did in your hotfix branch is not contained in the files in your iss53 branch. If you need to pull it in, you can merge your master branch into your iss53 branch by running git merge master, or you can wait to integrate those changes until you decide to pull the iss53branch back into master later.

Basic Merging

Suppose you’ve decided that your issue #53 work is complete and ready to be merged into your masterbranch. In order to do that, you’ll merge in your iss53 branch, much like you merged in your hotfix branch earlier. All you have to do is check out the branch you wish to merge into and then run the git mergecommand:

$ git checkout master
$ git merge iss53
Auto-merging README
Merge made by the 'recursive' strategy.
 README | 1 +
 1 file changed, 1 insertion(+)

This looks a bit different than the hotfix merge you did earlier. In this case, your development history has diverged from some older point. Because the commit on the branch you’re on isn’t a direct ancestor of the branch you’re merging in, Git has to do some work. In this case, Git does a simple three-way merge, using the two snapshots pointed to by the branch tips and the common ancestor of the two. Figure 3-16 highlights the three snapshots that Git uses to do its merge in this case.


Figure 3-16. Git automatically identifies the best common-ancestor merge base for branch merging.

Instead of just moving the branch pointer forward, Git creates a new snapshot that results from this three-way merge and automatically creates a new commit that points to it (see Figure 3-17). This is referred to as a merge commit and is special in that it has more than one parent.

It’s worth pointing out that Git determines the best common ancestor to use for its merge base; this is different than CVS or Subversion (before version 1.5), where the developer doing the merge has to figure out the best merge base for themselves. This makes merging a heck of a lot easier in Git than in these other systems.


Figure 3-17. Git automatically creates a new commit object that contains the merged work.

Now that your work is merged in, you have no further need for the iss53 branch. You can delete it and then manually close the ticket in your ticket-tracking system:

$ git branch -d iss53

Basic Merge Conflicts

Occasionally, this process doesn’t go smoothly. If you changed the same part of the same file differently in the two branches you’re merging together, Git won’t be able to merge them cleanly. If your fix for issue #53 modified the same part of a file as the hotfix, you’ll get a merge conflict that looks something like this:

$ git merge iss53
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.

Git hasn’t automatically created a new merge commit. It has paused the process while you resolve the conflict. If you want to see which files are unmerged at any point after a merge conflict, you can run git status:

$ git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")

Unmerged paths:
  (use "git add ..." to mark resolution)

        both modified:      index.html

no changes added to commit (use "git add" and/or "git commit -a")

Anything that has merge conflicts and hasn’t been resolved is listed as unmerged. Git adds standard conflict-resolution markers to the files that have conflicts, so you can open them manually and resolve those conflicts. Your file contains a section that looks something like this:

<<<<<<< HEAD

=======

>>>>>>> iss53

This means the version in HEAD (your master branch, because that was what you had checked out when you ran your merge command) is the top part of that block (everything above the =======), while the version in your iss53 branch looks like everything in the bottom part. In order to resolve the conflict, you have to either choose one side or the other or merge the contents yourself. For instance, you might resolve this conflict by replacing the entire block with this:

This resolution has a little of each section, and I’ve fully removed the <<<<<<<, =======, and >>>>>>> lines. After you’ve resolved each of these sections in each conflicted file, run git add on each file to mark it as resolved. Staging the file marks it as resolved in Git. If you want to use a graphical tool to resolve these issues, you can run git mergetool, which fires up an appropriate visual merge tool and walks you through the conflicts:

$ git mergetool

This message is displayed because 'merge.tool' is not configured.
See 'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse diffmerge ecmerge p4merge araxis bc3 codecompare vimdiff emerge
Merging:
index.html

Normal merge conflict for 'index.html':
  {local}: modified file
  {remote}: modified file
Hit return to start merge resolution tool (opendiff):

If you want to use a merge tool other than the default (Git chose opendiff for me in this case because I ran the command on a Mac), you can see all the supported tools listed at the top after “… one of the following tools:”. Type the name of the tool you’d rather use. In Chapter 7, we’ll discuss how you can change this default value for your environment.

After you exit the merge tool, Git asks you if the merge was successful. If you tell the script that it was, it stages the file to mark it as resolved for you.

You can run git status again to verify that all conflicts have been resolved:

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD ..." to unstage)

        modified:   index.html

If you’re happy with that, and you verify that everything that had conflicts has been staged, you can type git commit to finalize the merge commit. The commit message by default looks something like this:

Merge branch 'iss53'

Conflicts:
  index.html
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
#       .git/MERGE_HEAD
# and try again.
#

You can modify that message with details about how you resolved the merge if you think it would be helpful to others looking at this merge in the future — why you did what you did, if it’s not obvious.

 
read less
Comments
Dislike Bookmark

Looking for Advanced Java coaching

Find best Advanced Java coaching in your locality on UrbanPro.

FIND NOW

Lesson Posted on 30/05/2017 Advanced Java coaching Tuition/BCA Tuition Tuition/Engineering Diploma Tuition +4 Tuition/Engineering Diploma Tuition/Advanced Java Programming JSP Training IT Courses/Java IT Courses/Java/Core Java less

Create Immutable Class

Paras Chawla

Working as a Senior Software Developer(R and D) in the following technologies. 1. Java 2. J2EE/J2ME 3....

Snippet of an Immutable Class: package com.stringhr; /*Declare the class as 'final'. This would prevent any other class from extending it and hence from overriding any method from it which could modify instance variable values.*/ final class ImmutableClass { // private variables, thus invisible... read more

Snippet of an Immutable Class:

package com.stringhr;

/*Declare the class as 'final'. This would prevent any other class from extending it

and hence from overriding any method from it which could modify instance variable values.*/

final class ImmutableClass {

 // private variables, thus invisible beyond current class...

      private final int salary;

      private final String name;

 // private constructor, so that child class object can't be instantiated...

      private ImmutableClass(int salary, String name) {

            this.salary = salary;

            this.name = name;

      }

 // Only Getters, no Setter method so that no field can be modified

      public int getSalary() {

            return salary;

      }

      public String getName() {

            return name;

      }

}

Why is String immutable in Java?

The string is immutable for several reasons, here is a summary:

  • Security: Parameters are typically represented as String in network connections, database connection URLs, usernames/passwords etc. If it were mutable, these parameters could be easily changed.
  • String pool: If String weren’t immutable, then we never had a String pool great feature in String class. Let say:

String a=“Paras”;

String b=“Paras”

We all know that a and b points to the same Object in a heap if a changed to ”Chawla”, b will still point to “Paras” which is not possible if String weren’t immutable.

String a="Paras";

String b=a;

System.out.println(a==b);

a="Chawla";

System.out.println(a +b);

Output:

true

  • Synchronization and Concurrency: Making String immutable automatically makes them thread safe thereby solving the synchronization issues. Since String is immutable it can safely share between many threads which are very important for multithreaded programming and to avoid any synchronization issues in Java, Immutability also makes String instance thread-safe in Java, means you don't need to synchronize String operation externally.
  • Caching: When compiler optimizes your String objects, it seems that if two objects have the same value (a="test", and b=" test") and thus you need only one string object (for both a and b, these two will point to the same object). A string is immutable, no one can change its contents once created which guarantees hashCode of String to be same on multiple invocations.
  • Class loading: String is used as arguments for class loading. If mutable, it could result in the wrong class being loaded (because mutable objects change their state). Had String been mutable, a request to load "java.io.Writer" could have been changed to load "mil.vogoon.DiskErasingWriter"

If I have a class with all static members is it immutable?

If your class has only static members, then objects of this class are immutable, because you cannot change the state of that object (you probably cannot create it either).

read less
Comments
Dislike Bookmark

Lesson Posted on 29/05/2017 Advanced Java coaching Tuition/BA Tuition Tuition/BA Tuition/Programming in JAVA +6 Tuition/BCA Tuition Tuition/BCA Tuition/Java Programming Tuition/BTech Tuition Tuition/BTech Tuition/Java Programming Java Certification Classes IT Courses/Java less

Fractional Knapsack

Paras Chawla

Working as a Senior Software Developer(R and D) in the following technologies. 1. Java 2. J2EE/J2ME 3....

Algorithm - Fractional Knapsack import java.util.Scanner; public class Knapsack01 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); // 1 int W = scan.nextInt(); // 1000 float value[]... read more

Algorithm - Fractional Knapsack

 

import java.util.Scanner;

 

public class Knapsack01 {

     public static void main(String[] args) {

           Scanner scan = new Scanner(System.in);

           int n = scan.nextInt(); // 1

           int W = scan.nextInt(); // 1000

           float value[] = new float[n]; // 500

           float weight[] = new float[n]; // 30

           float ratio[] = new float[n];

           for (int i = 0; i < n; i++) {

                value[i] = scan.nextInt();

                weight[i] = scan.nextInt();

                ratio[i] = value[i] / weight[i];

           }

           float totalValue = knapSack01(W, value, weight, ratio, n);

           System.out.println(totalValue);

     }

 

     public static float knapSack01(float W, float[] value, floatweight[], float ratio[],

                int n) {

           float V = 0;

           while (n>0 && W!=0) {

                int mI = maxIndex(n, ratio);

                float w=min(weight[mI],W);

                // W=40,weight[2]=30 // W=10,weight[0]=20;

                W = W - w;

                V = V + w*ratio[mI];

                weight[mI]=weight[mI]-w;

                ratio[mI] = 0;

                n--;

           }

           return V;

     }

     public static float min(float a,float b){

           return a>b?b:a;

     }

 

     public static int maxIndex(int n, float ratio[]) {

           float largest = Integer.MIN_VALUE;

           int lastIndex = 0;

           for (int i = 0; i < n; i++) {

                if (ratio[i] > largest) {

                     largest = ratio[i];

                     lastIndex = i;

                }

           }

           return lastIndex;

     }

}

 

Output:

Input: 3 50

60 20 100

50 120 30

 

Output: 180.0000

read less
Comments
Dislike Bookmark

Looking for Advanced Java coaching

Find best Advanced Java coaching in your locality on UrbanPro.

FIND NOW

Lesson Posted on 29/05/2017 Advanced Java coaching Tuition/BA Tuition Tuition/BA Tuition/Programming in JAVA +8 Tuition/BCA Tuition Tuition/BCA Tuition/Java Programming Tuition/BTech Tuition Tuition/BTech Tuition/Java Programming Tuition/Engineering Diploma Tuition Tuition/Engineering Diploma Tuition/Advanced Java Programming Tuition/Engineering Diploma Tuition/Java Programming IT Courses/Java Script Training less

Simple Algorithms - Fibonacci, Finding GCD & Finding LCM.

Paras Chawla

Working as a Senior Software Developer(R and D) in the following technologies. 1. Java 2. J2EE/J2ME 3....

import java.util.Scanner; //0,1,1,2,3,5,8,13,21,34... //fun(n)=fun(n-1)+fun(n-2) where n>=2 /*fib(9)=fib(8)+fib(7) =fib(7)+fib(6)+fib(6)+fib(5) =fib(6)+fib(5)+fib(5)+fib(4)+fib(5)+fib(4)+fib(4)+fib(3) */ public class FibonacciNumberFast { public static void main(String[] args) { ... read more

import java.util.Scanner;

 

//0,1,1,2,3,5,8,13,21,34...

//fun(n)=fun(n-1)+fun(n-2) where n>=2

/*fib(9)=fib(8)+fib(7)

=fib(7)+fib(6)+fib(6)+fib(5)

=fib(6)+fib(5)+fib(5)+fib(4)+fib(5)+fib(4)+fib(4)+fib(3)

*/

public class FibonacciNumberFast {

     public static void main(String[] args) {

           Scanner scanner = new Scanner(System.in);

           int n = scanner.nextInt();

           long fno=fibonacciNumber(n);

           System.out.println(fno);  

     }

     public  static long fibonacciNumber(int n){

           int array[]= new int[n+1];

           array[0]=0;

           if(n==0)

                return array[0];

           array[1]=1;

           for(int i=2;i<=n;i++)

                array[i]=array[i-1]+array[i-2];

           return array[n];

     }

}

 

Algorithm 2– Finding GCD of a number

 1) GCD using Recursion

                          2) GCD using naïve approach

 

import java.util.Scanner;

 

// Largest number which divides both a and b

public class GCDNaive {

     public static void main(String[] args) {

           Scanner scanner = new Scanner(System.in);

           long a = scanner.nextLong();

           long b = scanner.nextLong();

           //long gcd = gcd(a, b);

           //System.out.println("Result from GCD Naive "+gcd);

           gcdFast(a, b);

     }

     static void gcdFast(long a, long b) {

           if (b == 0) {

                System.out.println(a);

           System.exit(0);

           }

           long rem=a%b;

           gcdFast(b, rem);

     }

/*   static long gcd(long a, long b) {

           long best = 0;

           for (long i = 1; i <= a + b; i++) {

                if ((a%i ==0) && (b%i== 0))

                     best = i;

           }

           return best;

     }

*/}


Algorithm 3 – Finding LCM of a number

 

import java.util.Scanner;

 

// GCD(a,b)*LCM(a,b)=a*b

public class LCM {

     public static void main(String[] args) {

           Scanner scanner = new Scanner(System.in);

           long a = scanner.nextLong(); // 8

           long b = scanner.nextLong(); // 6

           // long c = gcd(a, b);

           // System.out.println("GCD is" + c);

           long c = gcdFast(a, b);

           long d = (a * b) / c;

           System.out.println(d);

     }

 

     static long gcdFast(long a, long b) {

           if (b == 0) {

                return a;

           }

           long rem = a % b;

           long c=gcdFast(b, rem);

           return c;

     }

 

     /*   static long gcd(long a, long b) {

           long best = 0;

           for (long i = 1; i <= a + b; i++) {

                if ((a % i == 0) && (b % i == 0))

                     best = i;

           }

           return best;

     }*/

}

read less
Comments
Dislike Bookmark

Answered on 14/06/2017 IT Courses/Java/Core Java Advanced Java coaching

What is the fees of learning java at home from a reputed tutors like petaa byte institute ??

Ranjan K.

Tutor

I can train you in 10K per month
Answers 2 Comments
Dislike Bookmark

Answered on 16/05/2017 Advanced Java coaching Tuition/BA Tuition Tuition/BA Tuition/Data Structures +2 Tuition/BTech Tuition Tuition/BTech Tuition/Algorithms And Data Structures less

Prashanth K

Tutor

Two weeks.
Answers 42 Comments
Dislike Bookmark

Looking for Advanced Java coaching

Find best Advanced Java coaching in your locality on UrbanPro.

FIND NOW

Answered on 01/05/2017 Advanced Java coaching Tuition/BTech Tuition Tuition/BTech Tuition/Software Defined Networking

Chetana t.

Tutor

Max to max 1 week.
Answers 43 Comments 1
Dislike Bookmark

About UrbanPro

UrbanPro.com helps you to connect with the best Advanced Java coaching in India. Post Your Requirement today and get connected.

Overview

Questions 26

Lessons 32

Total Shares  

Top Contributors

Connect with Expert Tutors & Institutes for Advanced Java coaching

Advanced Java coaching in:

x

Ask a Question

Please enter your Question

Please select a Tag

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more