A silly code!
+2
BIT0107-Toma
BIT0102-Mohaimin
6 posters
Page 1 of 1
A silly code!
Note: I am trying to explain a very important thing for new/unexperienced java programmers. Experienced ones are requested not to answer the question I will ask later.
Carefully observe the Java code bellow. Do not run it. Try to compile in your mind!
Again I am telling, do not compile or run it in your PC. Just see the text and tell- what will be the output?
Carefully observe the Java code bellow. Do not run it. Try to compile in your mind!
- Code:
class A{
private B b;
public int getBValue(){
return b.getValue();
}
}
class B{
private int value;
public B(int value){
this.value = value;
}
public int getValue(){
return value;
}
}
class Main{
public static void main(String[] args) {
A a = new A();
B b = new B(3/3);
System.out.println(a.getBValue());
}
}
Again I am telling, do not compile or run it in your PC. Just see the text and tell- what will be the output?
BIT0102-Mohaimin- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 415
Points : 715
Re: A silly code!
According to Mohaimin, if I only think about IITans, only 2nd batch should reply here first.
Last edited by BIT0107-toma on Mon Jan 31, 2011 1:54 am; edited 1 time in total
BIT0107-Toma- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 280
Points : 453
Re: A silly code!
BIT0122-Amit wrote:No fair. You are not a 2nd batch Toma :p
Right you are
BIT0107-Toma- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 280
Points : 453
Re: A silly code!
I did not want to mean anything like that. Anyone who think he/she should answer can answer.BIT0107-toma wrote:According to Mohaimin, if I only think about IITans, only 2nd batch should reply here first.
BIT0102-Mohaimin- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 415
Points : 715
Re: A silly code!
Note: to compile this code, you need to be Java compatible. So first get and set Java environment in your mind.
I've compiled it, written in a log file, I think you guys are not interested to view my log. :p
Mohaimin, nice idea. Keep it up.
I've compiled it, written in a log file, I think you guys are not interested to view my log. :p
Mohaimin, nice idea. Keep it up.
Re: A silly code!
Trying to outsmart a compiler defeats much of the purpose of using one, don't you think?
BIT0130-Shakkhor- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 209
Points : 328
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Sep 29, 2015 2:45 pm by Sophiawood
» Cisco EHWIC SFP/GE WAN Card
Mon Sep 07, 2015 11:08 am by Sophiawood
» Huawei S1700-28GFR-4P-AC Price
Thu Jun 25, 2015 2:31 pm by Sophiawood
» teach yourself C++ / Herbert Schildt Solutions
Wed Jun 03, 2015 1:52 pm by Abdullah Al Noman
» teach yourself c by herbert schildt pdf
Wed May 13, 2015 11:01 pm by Raquib Ridwan
» ASA 5506X With Firepower ASA5506-K9
Fri Apr 10, 2015 4:31 pm by Sophiawood
» New Trends in Deal Business
Tue Feb 03, 2015 9:38 pm by nersoa
» PoE Power Allocation for WS-C2960S-24PS-L
Wed Nov 05, 2014 11:12 am by Sophiawood
» How to cure back pain
Fri Oct 31, 2014 7:15 pm by Bergen Guildford