Java and Python are two of most popular and powerful programming language of present time. Beginner programmer often get confused, one of the most frequently asked question is should I learn Java or Python, Is Python is good programming language to start with, Which programming language would you recommend for beginners to learn first etc. Since I am a Java developer, my opinion is biased, I will always suggest you to start with Java and then learn Python, but if you ask this question to a Python developer, you might get just opposite answer. I have well documented my reasons as Why Java is best Programming language and Why a programmer should learn Java. One of the most important reason you would see on that blog post is strong Java community, which will help you though out your Java career. You can ask some beginner stuff starting from how to set PATH and classpath to advanced stuff about debugging Java program in Eclipse, no matter what kind of question is, there is always some one is Java community, who is ready to answer and help you. This is one of the reason that StackOverflow is full of Java questions. By the way Python is not spring chicken anymore, it has fully grown and giving strong competition to main stream language like Java and C++. When I first come across Python, I thought it's a scripting language, but that is an understatement. You can do object oriented programming in Python as well. On beginners point of view, I always suggest pick a language which is easier to learn, powerful to attract you and have strong community support, now both Java and Python fits this bill, and until you do some really good comparative analysis, you can not decide which language to learn from Java vs Python. Thankfully, we have an infographic, which highlights some important difference between Python and Java, I am sure after taking a look on this Infographic, you will be able to decide which is the right programming language to start with.
Read more �
Friday, November 29, 2013
Thursday, November 28, 2013
Difference between static vs non static method in Java
In this article, we will take a look at difference between static and non static method in Java, one of the frequently asked doubt from Java beginner. In fact, understanding static keyword itself is one of the main programming fundamental, thankfully it's well defined in Java programming language . A static method in Java belongs to class, which means you can call that method by using class name e.g. Arrays.equals(), you don't need to create any object to access these method, which is what you need to do to access non static method of a class. Static method are treated differently by compiler and JVM than non static methods, static methods are bonded during compile time, as opposed to binding of non static method, which happens at runtime. Similarly you can not access non static members inside static context, which means you can not use non static variables inside static methods, you can not call non static methods from static ones, all those will result in compile time error. Apart from these significant differences between static and non static methods, we will also take a look at few more points in this Java tutorial, with a code example, which shows some of these differences in action.By the way this is the second article on static method, in first article, we have learned about when to use static method in Java
Read more �
Labels:
core java,
core java interview question,
programming
Tuesday, November 26, 2013
Monday, November 25, 2013
Informatique-solution de l'algorithm récursif : series d’exercice N01
Ex
01 :
Fonction Somme(n :entier) :entier
Début
Si n=0
alors
Somme <== 0
sinon
Somme <==Somme(n+1)+n
Fin
Ex
02 :
a)Fonction
quotion(a,b :entier) :entier
Début
Si
b<>0 alors
Début
Si a<b alors
quotion<== 0
Sinon
quotion <==quotion(a-b,b)+1
fin
sinon
quotion <== -1
Fin
b) Fonction
reste(a,b :entier) :entier
Début
Si a<b alors
reste <== a
Sinon
Reste <== reste (a-b,b)+1
Fin
Ex 03 :
Procédure
parcours (tete :pointeur)
Variable p :pointeur
i :entier
Début
p <== tete
i <== 0
Si p< > NIL alors
Début
…….(traiter(p))
Parcours(suivant(p))
Fin
Fin
Ex
04 :
Fonction
longer (tete :pointeur) :entier
Variable p :pointeur
Début
p <== tete
Si p= NIL alors
Longer <== 0
Sinon
Longer <==Longer(suivant(p)+1)
Fin
Ex
05 :
Fonction
count (tête :pointeur, val=entier) :entier
Variable p :pointeur
Début
p <== tête
Si p= NIL alors
Count<== 0
Sinon
count<== count(suivant(p)+1)
sinon
count<== count(suivant(p))
Fin
Ex
06 :
a)Fonction
Rech (tête :pointeur, val=entier) :entier
Variable p :pointeur
a:entier
Début
p<==tet
Si p= NIL alors
Rech<== NIL
Sinon
Si a=val alors
Rech <==p
Sinon
Rech<== Rech(suivant(p),val)
Fin
b)
Fonction
position (tête : pointeur, pos=entier) : pointeur
Variable p :pointeur
Début
p<== tête
Si
pos> 0 alors
début
Si pos=1
alors
position <== p
Sinon
Si p=NIL alors
position <== NIL
Sinon
position<== position(suivant(p),pos-1)
fin
Fin
Ex
07 :
Fonction
s-liste (tete-l,tete-sl :pointeur) :booléen
Variable p,q :pointeur
Début
p <== tète -l
q<== tète -sl
Si p= NIL
alors
s-liste <==faux
Si corespond(p,q) alors
s-liste <== vrai
Sinon
s-liste<== s-liste(suivant(p),q)
fin
Ex
08 :
Fonction somme(a,b :entier) :entier
Début
Si a< b
alors
Début
c<== a
a<== b
b<== c
fin
si b=0 alors
somme<== a
sinon
somme<== somme(a+1,b-1)
Fin
Ex
09 :
a)Fonction prod(t :tableau de
entier,n :entier) :entier
variable
i :entier
Début
Si n=1
alors
prod<== t[i]
sinon
prod <==prod(t,n-1)*t[n]
Fin
b)Fonction
moyenne(t :tableau[] :entier,n :entier) :entier
Début
Si n=1
alors
moyenne <==t[1]
sinon
moyenne <==((n-1)*moyenne (t,n-1)+t[n]) /n
Fin
Quand utiliser la récursivité ?
*Quand la
décomposition est simple à trouver et à comprendre .
Quand ne pas utiliser la récursivité ?
*Quand il
existe une solution itérative simple et intuitive.
*Quand la problème
de la récursivité est trop grand (dépassement possible de la pile d’exécution).