Preety Narashimhan

Greenhorn
+ Follow
since Aug 19, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Preety Narashimhan

That's bcoz the java.util.Date has a Default constructor, and the java.sql.Date does not have one..
this is the URL
www.jiris.com/mockexam
all the 3 mock exams ..
public class Test012
{
public static void main(String args[])
{
String s0 = new String("Java");
String s1 = s0.trim();
String s2 = s0.substring(0, 4);
String s3 = s0.toString();
System.out.println(s0 == s1);
System.out.println(s0 == s2);
System.out.println(s0 == s3);
}
}
The Answer to this is actually
true
true
true
The first and the Third case is understandable, but in the second case that is "substring" even the docs mention that a new String is returned.(though there is no mention about such an example!!).
Please explain, how can the second case return a true?
yeh was kinda confused with the wordings ...
Thanks a lot folks even the site turned out to be helpful !!!
What is the difference between the File and
RandomAccessFile classes?
(Select three correct answers)
A: The File class encapsulates the files and directories of the local file system.
B: The File and RandomAccessFile can be chained together in order to manipulate some files.
C: The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.
D: The File deals with byte while RandomAccessFile deals with char of the target file.
I did not understand how point A (that was a prt of the answer) could be the difference between File and RandomAccessFile classes???
Both of them encapsulates the files and directories of the local file system, nah ???
Thanks a lot..
was confused about the syncronization coz i did not see it specified in the API's
Thanks once again
1.Please clarify, if they do ask such questions in the SCJP1.2 examination about Class modifier called “strictfp” ??
2. Why is Vector said to be synchronized ? None of its methods are declared synchronized? Similarly in Hashtable?

:roll:
Agreed a base calss cannot access methods it does not ahve but a baseclass object referring to a subclass .. that shud b able to since it now no longer points to the base class but to the subclass rt?
17 years ago
Tx Barry,
But i am unable to understand, when the parent object (now referring to the subclass) cannot access any other methods of the SubClass( by which i mean those methods which are not overridden by the SubClass)...after all it has teh refernece of the SubClass ?
17 years ago
Hi all,
I have a problem here regd the base and sub class,
Assumen the subclass extends the base class.
SubClass objSC = new SubClass();
BaseClass objBC = objSC;
Now here the object of the BaseClass refers to the SubClass?
So all methods of the SubClass can be referred to by objBC?
17 years ago
sorry for the late reply ..was outa station..
hey tx a million all ya folks
so let me get things right..
1.Protected and Static classes need to be ineer classes.Cant they stand on their own?
2.Static methods can be overidden as in
public static void print() { System.out.println("Not Final, Static"); }
could be overidden as follows?
public static void print(String str) { System.out.println("Not Final, Static Overidden? :" + str); }
3.Basically there was a question which of teh following classes can be subclassed, and one of the options was a private class so i was wondering if they can be sub-classes at all?
4.Lance, the Void that u mention is it a Wrapper class?? Since it threw compilation errors when i tried to instantiate a void type variable or pass a void argument.
5.Eureka, the code u provided, has tehm as local objects, but it still on compilation of the SubClassB throws me this compilation error :
SubClassB.java:16: Invalid expression statement.
objRefA.superClassVarA; // 4
^
1 error
18 years ago
Hi folks,
List of doubts on Access Modifiers

1.Are there no protected classes?? Y not if “protected” signifies that it can be accessed/extended by the sub-classes.
2.Please give me a real example of static classes.
3.Is it possible to equate static methods with final methods??
4.Is it possible to sub-class a private class, when it is not even accessible?
5.Is void a datatype?
6.Consider the following eg:

public class SuperClassA{
protected int superClassVarA;
protected void superClassMethodA(){
System.out.println("In superClassMethodA method");
}
}
public class SubClassB extends SuperClassA{
SuperClassA objRefA = new SubClassB(); //1
SubClassB objRefB = new SubClassB(); //2
void subClassMethodB(){
objRefB.superClassMethodA(); //3
objRefA.superClassVarA; // 4
}
}
Here an object of the SuperClassA(objRefA) is referencing the object of the subclassB. Since the member variable “superClassVarA” is protected in the Superclass A, y is it not available to the SubclassB?
7. When a particular native method returns a class reference then how does java handle such a return value, when it does not even know the definition of hte class(the member variables and its methods)
18 years ago
hey Ron,
Since that part was just explaining the concept of the equals() method, instead of making the Pizza class i introduced two Strings in one of my classes.no separate code for the Pizza class was written.
Basically, when we use the new operator a separate memory area is created for the object and hence the equlas method returns a false.
ok..got it tx a lot
18 years ago
Hey tx for that "bit" of information worked wonders for me ...
18 years ago