What are virtual methods?
in java all function are virtual.only the function marked
with the final is not virtual.
means to say that if there is any method in super class and
you implemented this method in subclasses too.
then you can invoke on any subcalsses instances refer to
as a superclasses.and the method behaviour will change
according to subcallses instances .
class Amit
{
public void sleep()
{
System.out.println("amit slleping");
}
public static void main(String []args)
{
Amit a = new Amit();
a.sleep();
a = new Subclass1();
a.sleep();
a= new Subclass2();
a.sleep();
}
}
class Subclass1 extends Amit
{
public void sleep()
{
Sysetm.out.println("subclass sleeping");
}
}
class Subclass1 extends Amit
{
public void sleep()
{
System.out.println("subclass 2 sleeping");
}
}
so the output will be
amit sleeping
Subclass1 sleeping
Subclass2 sleeping
so the eat function behave virtualy for the differnt
instance .so this is called the virtual function .so don't
worry every function in java are virtual not the final
function.
Is This Answer Correct ? | 5 Yes | 0 No |
Is Java Class Threadsafe ????? How to make Java class Thread safe??
In the first round, there are 30 aptitude and 30 java questions. We are suppose to finish both the papers within 60 minutes. I cleared this round. Next was test for programming skills. In this section, Some 7 n's were asked. 1. What is the difference b/w sleep(1000) and wait(1000) 2. what is the diff b/w static block and static function? 3. Write a program to validate IP address using string tokenizer. 4. Write a program to create singleton class 5. write a function to reverse the string 6. Write a prog to print prime nos upto n. EX: If n=9, It shld print 1,2,3,5,7 7. One program on collections- Write a program to print no. of times a number is repeating in an array. EX- {1,3,1,2,5,7,3,7,34,3,8,3} It should print: 1- 2 times 3- 4 times and so on 7. Write a func to print fibonocci series After this I had technical interview, which went on for. 60 mins or so. There were qn's about multi threading, Exception handling and collection classes. Knowledge about collections was very important for the post I was interviewed for.
What is the difference between inheritance and encapsulation?
Explain the inheritance?
What is meant by flickering?
I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com
What is jar?
What are the types of web technologies?
what is net based application and its types
Can we restart a thread already started in java?
Difference between java and javascript
placement papaers of spring computing technology
0 Answers Spring Computing Technologies,