Core Java Doubts



Share on Google+Share on Google+

Core Java Doubts
1 Answer(s)      7 years ago
Posted in : Java Beginners
1)How to swap two numbers suppose a=5 b=10; without using third variable?
2)How to sort two strings? By using collections?
3)What is the difference between comparable and comparator?
4)When we go for Inheritance? And when we go for Interface?
5)What is difference between Abstraction and Encapsulation?
6)Give brief notes over collections? And their usage?
View Answers

June 5, 2010 at 4:03 PM

Hi Friend,

class Swapping {
public static void main(String[] args) {
int num1 = 5;
int num2 = 10;
num1 = num1 + num2;
num2 = num1 - num2;
num1 = num1 - num2;
System.out.println("After swapping, num1= " + num1 + " and num2= "+ num2);

import java.util.*;
class StringSort {
public static void main(String[] args){
String words[] = {"Rose","India"};
List list = Arrays.asList(words);


a)A comparable object is capable of comparing itself with another object while a comparator object is capable of comparing two different objects.

b)The Comparable class itself implements the java.lang.Comparable interface in order to compare its instances while the Comparator class does not compare its instances, but some other class?s instances.

For more information, visit the following links:

For inheritance and interface, visit the following links:


Abstraction - The process of abstraction in Java is used to hide certain details and only show the essential features of the object. In other words, it deals with the outside view of an object (interface).

Encapsulation - This is an important programming concept that assists in separating an object's state from its behavior. This helps in hiding an object's data describing its state from any further modification by external component. In Java there are four different terms used for hiding data constructs and these are public, private, protected and package. As we know an object can associated with data with predefined classes and in any application an object can know about the data it needs to know about. So any unnecessary data are not required by an object can be hidden by this process. It can also be termed as information hiding that prohibits outsiders in seeing the inside of an object in which abstraction is implemented.

For Collections, visit the following link:



Related Tutorials/Questions & Answers:
Core Java Doubts - Java Beginners
Core Java Doubts  1)How to swap two numbers suppose a=5 b=10; without...:// and interface, visit the following links:
Doubts in Java - Java Beginners
Doubts in Java  Hello sir have u got my mail........... if yes plzzzzzzzzz do the changes and forward it to me.......... waiting for ur reply :( plzzzzzzzz help me out
Doubts regarding Hashtable - Java Beginners
Doubts regarding Hashtable  Hi, I am new to hashtable.Is it possible to create a hashtable like this? java.util.Hashtable hashtable=new... information, Thanks
more doubts sir. - Java Beginners
more doubts sir.  Hello sir, Sir i have executed your code and i got the result but the problem is whenever i click on the link in my browser the link is opened in the internet explorer.i need to open the link also in my
structs doubts
structs doubts   i tried the fileupload program which is published in roseindia i am getting fileupload page after that when select any file to upload then i click upload i am getting following error
doubts for sub queries in mysql
doubts for sub queries in mysql  how to display the details of one table by checking the conditions in the next table using some condition eg., mysql> select * from student where number=(select id from studentpersonal where
Doubts on Struts 1.2 - Struts
Doubts on Struts 1.2  Hi, I am working in Struts 1.2. My requirement is to display data in a multiple selected box from database in a JSP page. Can anyone suggest me how to proceed... Thanx in advance  Hi friend
Doubts regarding images
Doubts regarding images  hello, I am dynamically generating an image in my system with out using database.. And i want the same image if i access the address bar url in other system image xhould be occur in other system
core java
core java  how to display characters stored in array in core java
Doubts in PlaceAd.jsp - JSP-Servlet
Doubts in PlaceAd.jsp  In DraftAd when user types in the textarea then it should get converted into digits and should get displayed in count box. in words that is how many words user have typed and there should be limit upto only
core java
core java  basic java interview question
core java
core java  i need core java material   Hello Friend, Please visit the following link: Core Java Thanks
core java
core java  Hi, can any one expain me serialization,Deseralization and exterenalization in core java
core java
core java  Hi, can any one exain me the concept of static and dynamic loading in core java
core java
core java  how can we justify java technology is robust
Core JAva
Core JAva  how to swap 2 variables without temp in java
core java - Java Beginners
core java  i want to get java projects in core java
core java
core java  write a java program to view product details from product table
Core Java
Core Java  How to execute cmd command through java?? Give Code of them
core java
core java  its compulsory to save file name and class name is same in java
CORE JAVA  What is Garbage collection in java? What is the role of a developer for garbage collection
core java
core java  In java primitive variables will get its default value automatically after declaration. Then why it is mandatory to initialize a variable before using
Core Java
Core Java  Please write a Java Program to design login form and store the values in file & validate and display the MainForm
Core Java
Core Java  Hi, Can any one please share the code for Binary search in java without using builtin function
core java
core java  Hello sir,What is logic behinde the core java programms,How may programmas are there,for example,sorting of two numbers,grade of the student details,fibonice serice,paldroma,incremting of the program,asscedding
core java
core java  Hello sir,What is logic behinde the core java programms,How may programmas are there,for example,sorting of two numbers,grade of the student details,fibonice serice,paldroma,incremting of the program,asscedding
Core Java
Core Java   How can i write own compile time and runtime exceptions in java   Hello Friend, Please visit the following links: http
Core Java
Core Java  Is Java supports Multiple Inheritance? Then How ?   Hi Friend, Java does not support multiple inheritance but it can be achieved by using the interface. In Java, Multiple Inheritance can be achieved through
Core Java
Core Java  How to load class dynamically in java ?   To load class dynamically you can use Class class method Class.forName(""); This method load the given class at run time


Advertisement null