Take BA Tuition from the Best Tutors
Search in
Lesson Posted on 17/11/2023 Learn Programming in JAVA
Bombay Academy
I am a programmer with almost a decade of experience in bangalore working on diverse technologies covering...
Lesson Posted on 30/12/2020 Learn Programming in JAVA
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{
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
Lesson Posted on 19/06/2019 Learn Programming in JAVA
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 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
Take BA Tuition from the Best Tutors
Lesson Posted on 01/11/2018 Learn Programming 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 less
Lesson Posted on 11/10/2018 Learn Programming in JAVA
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) { 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.
Lesson Posted on 26/09/2018 Learn Programming in JAVA
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 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 lessTake BA Tuition from the Best Tutors
Asked on 12/01/2018 Learn Programming in JAVA
Can you override a private or static method in Java?
Lesson Posted on 20/11/2017 Learn Programming in JAVA
Vivek Ranjan Sahu
Experienced and qualified teachers are everywhere now-a-days. But along with that, I am also an analyser...
Lesson Posted on 20/11/2017 Learn Programming in JAVA
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 |
|
|
Take BA Tuition from the Best Tutors
Lesson Posted on 20/11/2017 Learn Programming in JAVA
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 |
|
|
UrbanPro.com helps you to connect with the best BA Tuition in India. Post Your Requirement today and get connected.
Ask a Question
The best tutors for BA Tuition Classes are on UrbanPro
The best Tutors for BA Tuition Classes are on UrbanPro