InterviewSolution
| 1. |
You Can Create A String Object As String Str = "abc"; Why Cant A Button Object Be Created As Button Bt = "abc";? Explain |
|
Answer» The MAIN reason you cannot create a button by Button BT= "abc"; is because "abc" is a literal string (something slightly DIFFERENT than a String object, by-the-way) and bt is a Button object. The only object in JAVA that can be ASSIGNED a literal String is java.lang.String. Important to note that you are NOT calling a java.lang.String constuctor when you type String s = "abc"; The main reason you cannot create a button by Button bt= "abc"; is because "abc" is a literal string (something slightly different than a String object, by-the-way) and bt is a Button object. The only object in Java that can be assigned a literal String is java.lang.String. Important to note that you are NOT calling a java.lang.String constuctor when you type String s = "abc"; |
|