Study Anytime Any Where We Will Open The Knowledge For You Anish Sir 24x7 Learning solution It Is Time to join JOB
23 October 2017

Study Anytime Any Where

23 October 2017

We Will Open The Knowledge For You

23 October 2017

Anish Sir 24x7 Learning solution

23 October 2017

It Is Time to join JOB

C Programming

C++ Programming

JAVA Programming

Android Language

Android-logo.png

.Net Programming

net-logo-b55c217213ae49991589ed43d7ed58a7.png

c# Programming

photo_1389636992_quiz_image_temp.png

Asp .Net

asplogo-square.png

PHP Programming

58481791cef1014c0b5e4994.png

Search Your Topic

config
Anish Sir

Anish Sir

"I am delighted once again to pen the welcome note to the Tosh!Yas Technologies ."

 Call +91 74 88 34 7779  | Email : anishsingh@live.com

Website URL: http://toshiyas.in
Monday, 28 August 2017 10:00

I'm trying + (verb)

'I am trying' informs someone that you are attempting to accomplish something using bodily, mental, or spiritual strength. By adding a verb to 'I'm trying' you are pointing out exactly what it is you are attempting to do.

Here are some examples:

"I'm trying to get a job."
"I'm trying to call my family."
"I'm trying to enjoy my dinner."
"I'm trying to educate myself."
"I'm trying to explain myself."
"I'm trying new food."
"I'm trying to eat healthy."
"I'm trying to understand."

You may also hear the word 'trying' used to express a way someone is feeling. In this manner, it expresses strain or distress.

Here are some examples:

"Learning new things can be trying on you."
"That marathon was very trying on me."

Monday, 28 August 2017 09:59

I'm getting

When combining the words 'I am' and 'getting' you are telling someone 'you' are gaining possession, being affected by or have plans to seek out and obtain a particular thing.

Here are some examples:

"I'm getting better."("मेरी हालत बेहतर हो रही है।")
"I'm getting ready for bed."("मैं बिस्तर पर जाने के लिए तैयार हूं।")

"I'm getting a tooth ache."("मेरे एक दांत में दर्द हो रहा है।")
"I'm getting a cold."("मुझे सर्दी हो रही है।")
"I'm getting married."("मैं विवाह कर रहा हूँ।")

"I'm getting tired."("मुझे थकान हो रही है।")

"I'm getting good at reading."("मैं पढ़ाई में सुधार कर रहा हूं।")

"I'm getting a new car."("मुझे एक नई कार मिल रही है।")
"I'm getting a job."("मुझे नौकरी मिल रही है।"
"I'm getting a puppy."("मुझे एक पिल्ला मिल रहा है।")

Monday, 28 August 2017 09:58

I'm + (verb)

'I'm' is a contraction of the words 'I am.' By adding a verb to 'I'm' this lets you express an action or occurrence about yourself.

Here are some examples:

"I'm eating lunch."("मैं दोपहर का भोजन खा रहा हूं।")

"I'm brushing my teeth."("मैं अपने दांत साफ़ कर रहा हूँ।")

"I'm scared."("मुझे डर लग रहा है।")

"I'm driving to work."("मैं काम करने के लिए गाड़ी चला रहा हूँ।")
"I'm crying."("मैं रो रहा हूँ।")

"I'm typing an email."("मैं एक ईमेल टाइप कर रहा हूँ।")
"I'm cooking dinner."("मैं रात का खाना पका रहा हूँ।")

"I'm combing my hair."("मैं अपना बाल संवार रहा हूं।")

"I'm hanging a picture."("मैंने एक तस्वीर लटकाई है।")

"I am texting."("मैं संदेश भेज रहा हूँ।")
"I am dancing."("मैं नाच रहा हूँ।")
"I am interested in the job."("मेरी काम में दिलचस्पी है।")

"I am exercising."("मैं व्यायाम कर रहा हूं।")
"I am sad."("मैं दुखी हूँ।")

"I am learning."("मैं सीख रहा हूँ।")

Monday, 28 August 2017 09:49

I'm good at

Again, 'I'm' is used here as 'I am.' 'Good at' informs someone what you excel at and are comfortable doing.

Here are some examples:

"I'm good at drawing."("मैं ड्राइंग में अच्छा हूँ")

"I'm good at video games."("मैं वीडियो गेम में अच्छा हूँ।")
"I'm good at swimming."("मैं तैराकी में अच्छा हूँ।")
"I'm good at driving."("मैं ड्राइविंग में अच्छा कर रहा हूँ।")
"I'm good at reading."("मैं पढ़ने में अच्छा कर रहा हूँ।")
"I'm good at sports."("मैं खेल में अच्छा हूँ।")
"I'm good at writing."("मैं लिखने में अच्छा हूँ।")
"I'm good at math."("मैं गणित में अच्छा कर रहा हूँ।")
"I'm good at dancing."("मैं नृत्य करने में अच्छा हूँ।")
"I'm good at chess."("मैं शतरंज में अच्छा हूं।")

Monday, 28 August 2017 09:46

I'm in/at/on

Most commonly, you would use the word 'in' when entering a physical location such as a room or a building.

Here are some examples:

"I'm in the shower."("मैं शॉवर में हूं।")

"I'm in the lobby."("मैं आंगन में हूँ।")
"I'm in a car."("मैं एक कार में हूं।")
"I'm in a house."("मैं एक घर में हूं।")
"I'm in a school."("मैं एक स्कूल में हूँ।")

Using the word 'at' helps tell someone where you currently are. The difference between 'at' and 'in' is that the physical location is general.

Here are some examples:

"I'm at the grocery."("मैं किराने की दुकान पर हूं।")

"I'm at the mall."("मैं मॉल में हूँ।")

"I'm at the doctor's office."("मैं डॉक्टर के कार्यालय में हूं।")
"I'm at the park."("मैं पार्क में हूँ।")
"I'm at the airport."("मैं हवाई अड्डे पर हूं।")


However, in some cases you can use 'at' and 'in' interchangeably.

Here are some examples:

"I'm at the mall."("मैं मॉल में हूँ।")

"I'm in the mall."("मैं मॉल में हूँ।")
"I'm at the park."("मैं पार्क में हूँ।")
"I'm in the park."("मैं पार्क में हूँ।")
"I'm at the grocery."("मैं किराने की दुकान पर हूं।")
"I'm in the grocery."("मैं किराने में हूं।")

Using the word 'on' is referring to a non physical location such as your time being utilized by something else.

Here are some examples:

"I'm on the phone."("मै फ़ोन पर हूँ।")

"I'm on my computer."("मैं अपने कंप्यूटर पर हूं।")
"I'm on a bus."("मैं बस में हूँ।")

Monday, 28 August 2017 07:29

I'm

'I'm' is an abbreviation for the word 'I AM.' It is used in combination with other words to tell someone about yourself or to describe something you are doing.

Here are some examples:

"I'm so tired."("मैं बहुत थक गया हूँ।")
"I'm confused."("मैं उलझन में हूं।")
"I'm happy."("में खुश हूँ।")

"I'm twenty three years old."(मैं तेईस साल का हूँ। ")
"I'm hungry."("मुझे भूख लगी है।")

"I'm nervous."("मैं घबरा रहा हूँ।")

"I'm excited."("में उत्साहित हु।")

"I'm leaving work."("मैं काम छोड़ रहा हूं।")

"I'm thirsty."("मैं प्यासा हूँ।")
"I'm from Seattle."("मैं सीएटल से हूँ।")


You can also add descriptive words with 'I'm' such as:

"I'm extremely tired."("मैं बहुत थका हुआ हूँ।")
"I'm very happy."("मैं बहुत खुश हूँ।")
"I'm terribly hungry."("मै बहुत जय़ादा भूखा हूॅ।")

"I am super excited."("मैं बहुत उत्साहित हूँ।")

"I'm very nervous."("मैं बहुत घबराया हुआ हूँ।")

Monday, 28 August 2017 06:56

English Speaking

Tuesday, 08 August 2017 04:35

Java Interview Questions

Q) What is polymorphism ?

Ans) The ability to define a function in multiple forms is called Polymorphism. In java, c++ there are two types of polymorphism: compile time polymorphism (overloading) and runtime polymorphism (overriding).

Method overriding: happens when a child class implements the method with same signature as a method in a parent class. When you override methods, JVM determines the proper methods to call at the program’s runtime, not at the compile time.

Method overloading: happens when several methods have same names but different number or type of parameters. Overloading is determined at the compile time.

  • Overloading happens when:
  • Different method signature and different number or type of parameters.
  • Same method signature but different number of parameters.
  • Same method signature and same number of parameters but of different type
Example of Overloading
int add(int a,int b)
 float add(float a,int b)
 float add(int a ,float b)
 void add(float a)
 int add(int a)
 void add(int a) //error conflict with the  method int add(int a)
class BookDetails {
  String title;
  setBook(String title){}
}
class ScienceBook extends BookDetails {
  setBook(String title){} //overriding
  setBook(String title, String publisher,float price){} //overloading
}
 

Q) What is use of serialVersionUID?

Ans) The default Java serialization mechanism writes the metadata about the object, which includes the class name, field names and types, and superclass. This class definition is stored as a part of the serialized object. This stored metadata enables the deserialization process to reconstitute the objects and map the stream data into the class attributes with the appropriate type
Everytime an object is serialized the java serialization mechanism automatically computes a hash value. ObjectStreamClass's computeSerialVersionUID() method passes the class name, sorted member names, modifiers, and interfaces to the secure hash algorithm (SHA), which returns a hash value.The serialVersionUID is also called suid.
So when the serilaize object is retrieved , the JVM first evaluates the suid of the serialized class and compares the suid value with the one of the object. If the suid values match then the object is said to be compatible with the class and hence it is de-serialized. If not InvalidClassException exception is thrown.

Changes to a serializable class can be compatible or incompatible. Following is the list of changes which are compatible:

  • Add fields
  • Change a field from static to non-static
  • Change a field from transient to non-transient
  • Add classes to the object tree

List of incompatible changes:

  • Delete fields
  • Change class hierarchy
  • Change non-static to static
  • Change non-transient to transient
  • Change type of a primitive field

So, if no suid is present, inspite of making compatible changes, jvm generates new suid thus resulting in an exception if prior release version object is used .

The only way to get rid of the exception is to recompile and deploy the application again.

If we explicitly mention the suid using the statement:
private final static long serialVersionUID = <integer value>

then if any of the metioned compatible changes are made the class need not to be recompiled. But for incompatible changes there is no other way than to compile again.

Q) What is the difference between final, finally and finalize() in Java?

Ans) final - A final variable acts as a constant, a final class is immutable and a final method cannot be override in a child class.

finally - finally keyword is used with try-catch block for handling exception. The finally block is optional in try-catch block. The finally code block is always executed after try or catch block is completed. The general use case for finally block is to close the resources or clean up objects used in try block. For e.g. Closing a FileStream, I/O stream objects, Database connections, HTTP connections are generally closed in a finally block.

finalize() - This is the method of Object class.It is invoked before an object is discarded by the garbage collector, allowing it to clean up its state. Should not be used to release non-memory resources like file handles, sockets, database connections etc because Java has only a finite number of these resources and you do not know when the garbage collection is going to kick in to release these non-memory resources through the finalize() method.

Q4)What is difference between HashMap and HashTable?

Ans) Both collections implements Map. Both collections store value as key-value pairs. The key differences between the two are:

  1. Hashmap is not synchronized in nature but hashtable is(thread-safe). This means that in a multithreaded application, only one thread can gets access to a hashtable object and do an operation on it. Hashmap doesn't gurantee such behavior and is not used in multithreaded environment.
  2. Hashmap is traveresed using an iterator, hashtable can be traversed by enumerator or iterator.
  3. Iterator in hashmap is fail-fast, enumerator in hashtable is not fail-fast
  4. HashMap permits null values and only one null key, while Hashtable doesn't allow key or value as null.
  5. Since hashtable is synchornized, it is relatively slower in performance than hashmap

Q) What is difference between abstract class and interface ?

Ans) A class is called abstract when it is declared with keywordabstract. Abstract class contains atleast one abstract method. It can also contain n numbers of concrete method. Interface can only contain abstract methods.

  • Interface can have only abstract methods. Abstract class can have concerete and abstract methods.
  • The abstract class can have public, private, protected or default variables and also constants. In interface the variable is by default public final. In nutshell the interface doesnt have any variables it only has constants.
  • A class can extend only one abstract class but a class can implement multiple interfaces. Abstract class doesn't support multiple inheritance whereas abstract class does.
  • If an interface is implemented its mandatory to implement all of its methods but if an abstract class is extended its mandatory to implement all abstract methods.
  • The problem with an interface is, if you want to add a new feature (method) in its contract, then you MUST implement those method in all of the classes which implement that interface. However, in the case of an abstract class, the method can be simply implemented in the abstract class and the same can be called by its subclass.

 

Q) What is the difference between equals() and == ?

Ans) == operator is used to compare the references of the objects. 
public bollean equals(Object o) is the method provided by the Object class. The default implementation uses == operator to compare two objects. But since the method can be overriden like for String class. equals() method can be used to compare the values of two objects.

String str1 = "MyName"; 
String str2 = "MyName";
String str3 = new String(str2);

if (str1 == str2) {
  System.out.println("Objects are equal")
}else{
  System.out.println("Objects are not equal")
}
if(str1.equals(str2)) {
  System.out.println("Objects are equal")
} else {
  System.out.println("Objects are not equal")
}

Output:
Objects are not equal
Objects are equal
String str2 = "MyName";
String str3 = str2;
if (str2 == str3) {
System.out.println("Objects are equal")
}else{
System.out.println("Objects are not equal")
}
if (str3.equals(str2)) {
  System.out.println("Objects are equal")
} else {
  System.out.println("Objects are not equal")
}

Output:
Objects are equal
Objects are equal

Q) What is difference between a thread and a process?

Ans)

  • Threads share the address space of the process that created it; process has it's own address space.
  • Threads have direct access to the data segment of its process; processes have their own copy of the data segment of the parent process.
  • Threads can directly communicate with other threads of its process; processes must use interprocess communication to communicate with sibling processes.
  • Threads have almost no overhead; processes have considerable overhead.
  • New threads are easily created; new processes require duplication of the parent process.
  • Threads can exercise considerable control over threads of the same process; processes can only exercise control over child processes.
  • Changes to the main thread (cancellation, priority change etc.) may affect the behavior of the other threads of the process; changes to the parent process do not affect child processes.

Q) What is use of synchronized keyword?

Ans) synchronized keyword can be applied to static/non-static methods or a block of code. Only one thread at a time can access synchronized methods and if there are multiple threads trying to access the same method then other threads have to wait for the execution of method by one thread. Synchronized keyword provides a lock on the object and thus prevents race condition. E.g.

public void synchronized method(){} 
  public void synchronized staticmethod(){}
  public void myMethod(){
     synchronized (this){ 
        //synchronized keyword on block of code
     }
  }

Q)Is garbage collector a dameon thread?

Ans) Yes GC is a dameon thread. A dameon thread runs behind the application. It is started by JVM. The thread stops when all non-dameon threads stop.

Q)How is Garbage Collection managed?

Ans)The JVM controls the Garbage Collector; it decides when to run the Garbage Collector. JVM runs the Garbage Collector when it realizes that the memory is running low. The behavior of GC can be tuned by passing parameters to JVM. One can request the Garbage Collection to happen from within the java program but there is no guarantee that this request will be taken care of by jvm.

Saturday, 05 August 2017 08:10

Java JButton

The JButton class is used to create a labeled button that has platform independent implementation. The application result in some action when the button is pushed. It inherits AbstractButton class.

JButton class declaration

Let's see the declaration for javax.swing.JButton class.

 
  1. public class JButton extends AbstractButton implements Accessible  

Commonly used Constructors:

Constructor Description
JButton() It creates a button with no text and icon.
JButton(String s) It creates a button with the specified text.
JButton(Icon i) It creates a button with the specified icon object.

Commonly used Methods of AbstractButton class:

Methods Description
void setText(String s) It is used to set specified text on button
String getText() It is used to return the text of the button.
void setEnabled(boolean b) It is used to enable or disable the button.
void setIcon(Icon b) It is used to set the specified Icon on the button.
Icon getIcon() It is used to get the Icon of the button.
void setMnemonic(int a) It is used to set the mnemonic on the button.
void addActionListener(ActionListener a) It is used to add the action listener to this object.

Java JButton Example

 
  1. import javax.swing.*;    
  2. public class ButtonExample {  
  3. public static void main(String[] args) {  
  4.     JFrame f=new JFrame("Button Example");  
  5.     JButton b=new JButton("Click Here");  
  6.     b.setBounds(50,100,95,30);  
  7.     f.add(b);  
  8.     f.setSize(400,400);  
  9.     f.setLayout(null);  
  10.     f.setVisible(true);   
  11. }  
  12. }  

Output:

JAVA Jbutton 1


Java JButton Example with ActionListener

 
  1. import java.awt.event.*;  
  2. import javax.swing.*;    
  3. public class ButtonExample {  
  4. public static void main(String[] args) {  
  5.     JFrame f=new JFrame("Button Example");  
  6.     final JTextField tf=new JTextField();  
  7.     tf.setBounds(50,50150,20);  
  8.     JButton b=new JButton("Click Here");  
  9.     b.setBounds(50,100,95,30);  
  10.     b.addActionListener(new ActionListener(){  
  11. public void actionPerformed(ActionEvent e){  
  12.             tf.setText("Welcome to Javatpoint.");  
  13.         }  
  14.     });  
  15.     f.add(b);f.add(tf);  
  16.     f.setSize(400,400);  
  17.     f.setLayout(null);  
  18.     f.setVisible(true);   
  19. }  
  20. }  

Output:

JAVA Jbutton 2


Example of displaying image on the button:

 
  1. import javax.swing.*;      
  2. public class ButtonExample{    
  3. ButtonExample(){    
  4. JFrame f=new JFrame("Button Example");            
  5. JButton b=new JButton(new ImageIcon("D:\\icon.png"));    
  6. b.setBounds(100,100,10040);    
  7. f.add(b);    
  8. f.setSize(300,400);    
  9. f.setLayout(null);    
  10. f.setVisible(true);    
  11. f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    
  12.     }         
  13. public static void main(String[] args) {    
  14.     new ButtonExample();    
  15. }    
  16. }    

Output:

JAVA Jbutton 3

Page 5 of 31