In this post few questions with answers, theory part are posted for ICSE students of 2012. Read these answers and if any doubt, post your comments.
- What is private and public specifier in Java?
public and private are access specifiers used before variable declaration and function definition. ‘public’ members, whether used in function or variable can be accessed from outside the class body even outside the package while ‘private’ members can be accessed from only within the class body.
- Difference between ‘==’ and equals ()’.
‘==’ is an operator, relational operator used to compare equality of two primitive values and when this operator is used on objects, it compares the references of the objects for equality.
‘euqals ()’ is a String class function and prototype of this function is ‘boolean equals(String s)’. This function takes a String object as argument and compares the argument object and invoking object values for equality. This is a case sensitive function.
- Compare switch with else-if ladder.
Both switch and else-if are decision making statements which can operate successfully on multiple options. There are some differences between these two decision making statements.
else-if can work on any type of primitive values and objects while switch can work only on character and integer value.
In switch statement, logical operator can not be used while in else-if ladder, logical operators are used.
The statement ‘break’ is required at the end of each case body to send the control out of switch body while in case of else-if ladder, no such break statement is required.
else is optional part of else-if ladder and default is option part of switch statement. In else-if ladder, else has to be placed at the end of the ladder and in switch, default is normally placed at the end but it can be placed anywhere in the switch body.
Switch works
‘substring ()’ is a function of String class and return type of this function is String. This function has two overloaded versions. The prototypes are ‘String substring (int start)’ and ‘String substring (int start, int number)’.
‘charAt ()’ is a function of String class and prototype of the function is ‘char charAt(int i)’. This function returns the character of the specified location ‘I’ of the invoking string object.
- Comparision between break and continue
Both are jumoing statements while braek is used in loop and switch statements, continue is used on in loops. Break is used in loops for premature termination of the loop and the same statement is used in case body of switch statement to send the control out of switch body.
Continue is used in loops for premature iteration of the loop, means loop body starts executing skipping a part of statements in the loop body.
- Use of ‘this’ keyword.
‘this’ is a keyword used in java to refer the current object.
- Define entry control and exit control loop
hii sir this is anshu please sent some guess papers that could help me in the exams for ICSC
ReplyDeleteMy last post is on ICSE 2012 examination. Very soon I will post another two such. Please follow.
Delete