UrbanPro
true

Take BA Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Learn Programming in JAVA with Free Lessons & Tips

Ask a Question

Post a Lesson

All

All

Lessons

Discussion

Lesson Posted on 17/11/2023 Learn Programming in JAVA

Shell scripting video

Bombay Academy

I am a programmer with almost a decade of experience in bangalore working on diverse technologies covering...

https://vz-3ad30922-ba4.b-cdn.net/1e101a93-ed2d-445a-9c1d-27b0b774262d/play_480p.mp4
Comments
Dislike Bookmark

Lesson Posted on 30/12/2020 Learn Programming in JAVA +4 Java Core Java Java Programming JSP (Java Server Pages)

Java : Compile-time Versus Runtime optimization

Surinder Pal Singh

I have 10 years of experience, working with Top IT companies. During my work it have extensively used...

While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below : What is the difference between line 1 & line 2 in the following code snippet? public class CompileAndRuntimeTest{... read more

While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below :

 

What is the difference between line 1 & line 2 in the following code snippet?

 

public class CompileAndRuntimeTest{
     static final int number1 = 5;
     static final int number2 = 6;
     static int number3 = 5;
     static int number4= 6;

public static void main(String[ ] args) {
    int product1 = number1 * number2; //line 1
    int product2 = number3 * number4; //line 2
}
}

Line 1, evaluates the product at compile-time, and Line 2 evaluates the product at runtime. If you use a Java Decompiler (e.g. jd-gui), and decompile the compiled CompileAndRuntimeTest.class file, you will see why , as shown below:

 

public class CompileAndRuntimeTest
{
   static final int number1 = 5;
   static final int number2 = 6;
   static int number3 = 5;
   static int number4 = 6;

public static void main(String[ ] args)
{
   int product1 = 30;//line 1 ---Here is the diff. Decompiled code 
   int product2 = number3 * number4; //line 2
}
}

Constant folding is an optimization technique used by the Java compiler. Since final variables cannot change, they can be optimized. Java Decompiler and javap command are handy tool for inspecting the compiled (i.e. byte code ) code.

 

Question for readers  :)  :

Can you think of scenarios other than code optimization, where inspecting a compiled code is useful?

 

read less
Comments
Dislike Bookmark

Lesson Posted on 19/06/2019 Learn Programming in JAVA +3 Programming Languages C Language Basics of Programming and Data Structures

C, Cpp, Java, Python, Javascript Programming Languages

Vamshi

Learning C is as good as Learning a Natural Language(such as English, Hindi, Telugu, Tamil etc) We use Natural Languages to communicate with humans whereas we use Programming Languages such as C, Cpp, Java, Python to communicate with Compilers/Interpreters (which in turn communicate or translate... read more

Learning C is as good as Learning a Natural Language(such as English, Hindi, Telugu, Tamil etc)

 

We use Natural Languages to communicate with humans whereas we use Programming Languages such as C, Cpp, Java, Python to communicate with Compilers/Interpreters (which in turn communicate or translate our intent to Machines).

 

So, Learning C, boils down to, learning how to communicate with a C Compiler.

 

The following line is the CRUX of Programming

Programming Languages helps in the

        1. Comprehension,

        2. Automation, and

        3. Simulation of real-world scenarios.

 

Every phenomena in the world is nothing but

        a. a sequence of actions,

        b. with many alternatives ( selection of one of the alternatives),

        c. with repetitions of same sequence of actions with different alternatives

 

For Example, Tea Preparation consists of 

       1. a sequence of actions (in preparing tea)

       2. with an option to select sugar/honey/jaguery as sweetener

       3. repetition of (1) and (2) again and again when we desire to drink Tea/Coffee.

 

 So, a programming language should provide 

        sequence(writing statements one after the other)

        selection,  (if, if-else, else-if ladder, switch, ?:)

       iteration    (for, while, do-while)  constructs to simulate real-world scenarios.

 

A program once written to simulate the real-world scenario should be able to withstand the Universal Truth of “The only constant in life is change”.

 

Functions, Arrays, Pointers, Structures, Files helps in developing a robust program which can adapt to the changing environments with minimal maintaneance efforts.

 

So, the intent of any programming language (such as C, Cpp, Java, Python, javascript, Haskell, Scheme, ....) is to develop robust applications simulating real-world environments with minimum maintenance costs.

 

All the best for Your Learning.

 

 

read less
Comments
Dislike Bookmark

Take BA Tuition from the Best Tutors

  • Affordable fees
  • Flexible Timings
  • Choose between 1-1 and Group class
  • Verified Tutors

Lesson Posted on 01/11/2018 Learn Programming in JAVA +3 Java Java Programming Core Java

Class and Objects in Java

Asterix Solution

Asterix Solution is one of Mumbai's and Navi Mumbai's top leading IT Training Institute since 2104. We...

Class is a template or a blueprint which is used to describe an object. On other hand Object is a reference of a class which follows all the stuff written inside the class. How about taking the whole tour in the following video read more

Class is a template or a blueprint which is used to describe an object.

On other hand Object is a reference of a class which follows all the stuff written inside the class.

How about taking the whole tour in the following video

 

read less
Comments
Dislike Bookmark

Lesson Posted on 11/10/2018 Learn Programming in JAVA +4 Java Java Programming Core Java Advanced Java Programming

Java 8 Predicates

Shiva Kumar

I have completed Engineering in computer science in 2008. Since then,I have been working in IT industry...

In the previous lession, we have learnt how to use filters and collectors. In filter we have passed the condition to evaluate whether the object is eligible to be filtered or not. Code given below for reference and highlighted in bold. public class NowJava8 { public static void main(String args)... read more

In the previous lession, we have learnt how to use filters and collectors. In filter we have passed the condition to evaluate whether the object is eligible to be filtered or not. Code given below for reference and highlighted in bold.

public class NowJava8 {public static void main(String[] args) {List lines = Arrays.asList("abc", "xyz", "shiva");List result = lines.stream() .filter(line -> !"shiva".equals(line)) .collect(Collectors.toList()); result.forEach(System.out::println); //output : abc,xyz}}

Now, what if I would like to same condition in different places to filter on different collections. We would end up repleating same piece of code.
What does it mean? we break DRY (Do not repeat yourself).

Here to solve this we can use predicates. Example given below.
 import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class PredicatesExample
{
public static Predicate<String> isShiva() {
return s -> s.equalsIgnoreCase("shiva");
}


public static void main(String[] args) {
List<String> lines = Arrays.asList("abc", "xyz", "shiva");

List<String> result = lines.stream()
.filter(isShiva().negate())
.collect(Collectors.toList());

result.forEach(System.out::println); //output : abc,xyz
 
List<String> names = Arrays.asList("abc", "dhdh", "shiva","ddds","edsd");
 
 result =names.stream() 
.filter(isShiva().negate())
.collect(Collectors.toList()); 

result.forEach(System.out::println); //output : abc,dhdh,ddds,edsd
}
}  

As you see, we have used same predicate for two different collections.
read less
Comments
Dislike Bookmark

Lesson Posted on 26/09/2018 Learn Programming in JAVA +7 Java Java Script Training Java Programming Core Java JSP (Java Server Pages) Selenium with Java Advanced Java Programming

How can everyone prepare to clear any Java interview?

Bright Computer Education

Bright Computer Education is Vadodara based Institute, works on All India Computer Education Mission....

Java interview your java should be much strong then J2EE. core java and Advance java is the basic foundation for Interview. Some of the topic about which you should know before going for a java interview are mentioned below: 1-JRE, JDK & JVM 2-OOPS 3-Different scenarios related to oops like scenarios... read more

Java interview your java should be much strong then J2EE. core java and Advance java is the basic foundation for Interview. Some of the topic about which you should know before going for a java interview are mentioned below:

1-JRE, JDK & JVM

2-OOPS

3-Different scenarios related to oops like scenarios based on compile-time and runtime polymorphism, different type of inheritence

4-exception hierarchy, checked and unchecked exception, Different scenarios related to exceptions

5-Threads , their states and ways of creating threads.

6-Collection framework and difference between different collections.

7-Generics.

8-Hashcode and equals and their contract.

9-Difference between:

         String & StringBuffer

         equals and ==

         checked and unchecked exceptions

         interface and abstract class

          Thread class and runnable interface.

read less
Comments
Dislike Bookmark

Take BA Tuition from the Best Tutors

  • Affordable fees
  • Flexible Timings
  • Choose between 1-1 and Group class
  • Verified Tutors

Asked on 12/01/2018 Learn Programming in JAVA

Can you override a private or static method in Java?

Answer

Lesson Posted on 20/11/2017 Learn Programming in JAVA +5 Core Java Java Java Programming Java Programming Java Programming

Java: A Quick Overview

Vivek Ranjan Sahu

Experienced and qualified teachers are everywhere now-a-days. But along with that, I am also an analyser...

Not purely Object Oriented: It doesn't support multiple inheritence, it supports primitive data types and static members. Doesn’t support multiple inheritance: Reason is diamond problem i.e., if both parent classes have same method & not overridden by child, then at runtime ambiguity occurs. Platform... read more
  • Not purely Object Oriented: It doesn't support multiple inheritence, it supports primitive data types and static members.
  • Doesn’t support multiple inheritance: Reason is diamond problem i.e., if both parent classes have same method & not overridden by child, then at runtime ambiguity occurs.
  • Platform Independent: Compiled into platform independent bytecode.
  • Robust: Provides compile-time and runtime checks in order to eliminate error prone situations.
  • Multithreaded: Supports performing multiple tasks simultaneously.
  • Interpreted: Java bytecode is translated on the fly to native machine instructions and is not stored anywhere.
  • High Performance: Uses JIT compiler.
  • Secure.
  • Architectural neutral.
  • Portable.
  • Distributed.
  • Dynamic.
read less
Comments
Dislike Bookmark

Lesson Posted on 20/11/2017 Learn Programming in JAVA +5 Core Java Java Java Programming Java Programming Java Programming

Comparable vs Comparator

Vivek Ranjan Sahu

Experienced and qualified teachers are everywhere now-a-days. But along with that, I am also an analyser...

java.lang.Comparable java.util.Comparator For comparing some other object with its own object. Ex. I am comparing myself to some other employee. Method signature is: int compareTo (T object). For implementing Comparable, access to the original class is required. The class itself needs... read more
java.lang.Comparable java.util.Comparator
  1. For comparing some other object with its own object. Ex. I am comparing myself to some other employee.
  2. Method signature is: 
    int compareTo (T object).
  3. For implementing Comparable, access to the original class is required.
  4. The class itself needs to implement Comparable and hence it is inside java.lang package.
  5. It can be used to provide single way of sorting.
  1. For comparing two objects by a separate class. Ex. Manager is comparing two employees with each other.
  2. Method signature is:
    int compare (T object1, T object2).
  3. If the required class is not accessible i.e., present inside some jar, then a Comparator implementation can be used that just accepts the two objects and do the comparison.
  4. It is a utility that can be used by an external class to perform the required action and hence it is inside java.util package.
  5. It can be used to provide multiple sorting ways like NameComparator, SalaryComparator etc.
read less
Comments
Dislike Bookmark

Take BA Tuition from the Best Tutors

  • Affordable fees
  • Flexible Timings
  • Choose between 1-1 and Group class
  • Verified Tutors

Lesson Posted on 20/11/2017 Learn Programming in JAVA +5 Core Java Java Java Programming Java Programming Java Programming

ClassNotFoundException vs NoClassDefFoundError

Vivek Ranjan Sahu

Experienced and qualified teachers are everywhere now-a-days. But along with that, I am also an analyser...

ClassNotFoundException NoClassDefFoundError It is an exception and happens due to programmer’s mistake and can be recovered by updating the code. Thrown when an application tries to load a class through its String name using Class.forName or ClassLoader.findSystem or ClassLoader.loadClass... read more
ClassNotFoundException NoClassDefFoundError
  1. It is an exception and happens due to programmer’s mistake and can be recovered by updating the code.
  2. Thrown when an application tries to load a class through its String name using Class.forName or ClassLoader.findSystem or ClassLoader.loadClass methods.
  3. Thrown by application.
  1. It is an error and doesn’t happen due to programmer’s mistake and can’t be recovered by updating the code.
  2. Thrown if JVM is unable to find the class during runtime which was present at compile time. Ex. removing .class file just before running, will throw error.
  3. Thrown by JVM.
read less
Comments
Dislike Bookmark

About UrbanPro

UrbanPro.com helps you to connect with the best BA Tuition in India. Post Your Requirement today and get connected.

Overview

Lessons 22

Total Shares  

+ Follow 53,341 Followers

You can also Learn

Top Contributors

Connect with Expert Tutors & Institutes for Programming in JAVA

x

Ask a Question

Please enter your Question

Please select a Tag

X

Looking for BA Tuition Classes?

The best tutors for BA Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BA Tuition with the Best Tutors

The best Tutors for BA Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 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 7.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