a. Java Byte Code is the
language that the Java Virtual Machine understands. Java Compiler compiles the
source code into the Java Byte Code. Java is platform independent. So once
source code compiles into byte code it can execute on any platform wherever
Java Virtual Machine is installed.
b. .class is the file type, extension of Java Byte Code
c. By compiling a java source code file we can have the java byte
code.
d. int, byte, short, long
e.
i. wrong - It should be corrected as
char C1;
ii. correct
iii. wrong - long and int are two
different data types.
long m;
int m;
int m;
iv. wrong - no such data type call
bool. it should be boolean
f.
Arithmetic Operators + - / *
Bitwise Operators ~ & | ^ << >>
Relation Operators == != > < >= <=
Boolean Logical Operators & | ^ || && !
Arithmetic Operators + - / *
Bitwise Operators ~ & | ^ << >>
Relation Operators == != > < >= <=
Boolean Logical Operators & | ^ || && !
g.
i. 23 ගණිතකර්ම ප්රමුඛතා පිළිවෙල වන්නේ
1. ( ) 2. * 3. / 4. + 5. -
i. 23 ගණිතකර්ම ප්රමුඛතා පිළිවෙල වන්නේ
1. ( ) 2. * 3. / 4. + 5. -
ii. -2 %
මගින්
සංඛ්යාවක්
බෙදා
ඉතිරිය
ලබා
දේ.
iii. true පළමුව වරහන්
සුළු
වේ.
පහසුව
තකා, true=1,
false=0, ‘||’=+ සහ
‘&&’=* ලෙස
සලකන්න.
iv. 2 >> shift right.
shift කරන විට සංඛ්යා වල binary අගය ගන්න.
8 binary කලාම 1000
right shift කරන විට අදාළ binary සංඛ්යාවේ දකුණු පසින් දෙන ලද ඉලක්කම් ප්රමාණයක් හලන්න.
මෙහිදී නම් 1000 à 10
මේ උත්තරේ decimal කලාම final answer එක ලැබෙනවා. = 2
shift කරන විට සංඛ්යා වල binary අගය ගන්න.
8 binary කලාම 1000
right shift කරන විට අදාළ binary සංඛ්යාවේ දකුණු පසින් දෙන ලද ඉලක්කම් ප්රමාණයක් හලන්න.
මෙහිදී නම් 1000 à 10
මේ උත්තරේ decimal කලාම final answer එක ලැබෙනවා. = 2
h.
class
DesendingOrder{
public static void main(String
[] hansa){
int [] a = new
int[3];
for(int
i=0;i<3;i++){ // command line එකෙන් argument අරන්,
array 1 store කරගැනීමට
a[i]=Integer.parseInt(hansa[i]);
}
int t; // තාවකාලිකව array data එකක් save කර තබා ගැනීමට
for(int k=0;
k<3; k++){ // descend වීමට යා යුතු වාර ගණන
for(int
i=0; i<2; i++){ //array එකේ data, descend order කිරීමට
if(a[i]<a[i+1]){
t
= a[i]; // අඩු අගය t වලට save කරයි.
a[i]
= a[i+1]; // වැඩි අගය, අඩු අගය තිබුණු තැනට සමාන කරයි.
a[i+1]=t;
// වැඩි අගය තිබුණු තැනට, අඩු අගය සමාන කරයි
}
}
}
for(int
i=0;i<3;i++){ // descend order වූ array එක display කරයි.
System.out.println(""+a[i]);
}
}
}
i.
|
||
Question 2 Answers
a.
1. Classes and Object
2. Data Abstraction and Encapsulation
3. Inheritance
4. Polymorphism
5. Interfaces
6. Packages
b.
1. Eliminate Redundant Code – Inheritance භාවිතය
2. Save time and high productivity – create objects,
Reusability
3. Secure programs – Data Abstraction and
Encapsulation නිසා
4. Easy upgrading – පොඩි program එක software
එකක් වෙනකං
5. Simpler Interfaces – message passing techniques
c.
Structured
Programming
|
Object-Oriented
Programming
|
Top-down approach
is followed.
|
Bottom-up approach
is followed
|
Focus is on
algorithm and control flow.
|
Focus is on object
model
|
Program is divided
into a number of sub modules, or functions, or procedures.
|
Program is
organized by having a number of classes and objects.
|
Functions are
independent of each other
|
Each class is
related in a hierarchical manner.
|
No designated
receiver in the function call
|
There is a
designated receiver for each message
passing
|
Views data and
functions as two separate entities
|
Views data and
function as a single entity
|
Maintenance is
costly
|
Maintenance is
relatively cheaper.
|
Software reuse is
not possible
|
Helps in software
reuse
|
Function call is
used.
|
Message passing is
used
|
Function
abstraction is used
|
Data abstraction is
used.
|
Algorithm is given
importance.
|
Data is given
importance
|
Solution is
solution-domain specific
|
Solution is
problem-domain specific
|
No encapsulation.
Data and functions are separate
|
Encapsulation
packages code and data altogether. Data and functionalities are put together
in a single entity.
|
Relationship
between programmer and program is
emphasized
|
Relationship
between programmer and user is emphasized.
|
Data-driven
technique is used
|
Driven by
delegation of responsibilities.
|
No comments :
Post a Comment