2017-06-23

Use of java Class.forName

Class.forName use to load the class at run time. Which means its create instance of the class at run time, so that all static, block , variable ,class instance are available.

Example:

Class x=Class.forName("className");

Java class loader example

Java Classloader is a part of the Java Runtime Environment that dynamically loads Java classes into the Java Virtual Machine. classes are only loaded on creation of an object.

Three class loaders are used:


  1. Bootstrap class loader
  2. Extensions class loader
  3. System class loader


The bootstrap class loader loads the core Java libraries located in the <JAVA_HOME>/jre/lib directory. This class loader, which is part of the core JVM, is written in native code.

The extensions class loader loads the code in the extensions directories (<JAVA_HOME>/jre/lib/ext, or any other directory specified by the java.ext.dirs system property). It is implemented by the sun.misc.Launcher$ExtClassLoader class.

The system class loader loads code found on java.class.path, which maps to the CLASSPATH environment variable. This is implemented by the sun.misc.Launcher$AppClassLoader class.

2017-06-22

convert string to int without parseint

Convert string to integer without using build in api Integer.parseInt()

   Using this concept we can convert String to Number, String to Float, String to Double, String to short and long
                                                       
ASCII code of decimal number start form 48

  • public class ConvertStringToInt {

  • public static void main(String[] args) {
  • String str="-14545";
  • int total=0;
  • boolean m=false;
  • for(int i=0;i<str.length();i++){
  • if(str.charAt(i)=='-'){
  • m=true;
  • continue;
  • }
  • if(str.charAt(i)=='+'){
  • continue;
  • }
  • total=(total*10)+(str.charAt(i)-48);
  • }
  • if(m){
  • total=0-total;
  • }
  • System.out.println(total);


  • }

  • }



2017-06-15

Chance problems program

Generating Chance of getting 0 is 75% percent and 1 is 25% percent probability

  1. import java.util.Random;

  2. public class Chance {

  3. public static int getChance(){
  4. Random randomNumber = new Random();
  5. int randomGenerator = randomNumber.nextInt(100);
  6. System.out.println(randomGenerator);
  7. if(randomGenerator < 75)
  8. return 0;
  9. else 
  10. return 1;
  11. }
  12. public static void main(String[] args) {

  13. for(int i=0;i<10;i++){
  14. System.out.println(Chance.getChance());
  15. }
  16. }

  17. }


2017-06-07

java : operator example

java : operator example

public class Array2 {

public static void main(String[] args) {
int[] arr={1,2,3,4,5,0,0,1,3};
Outer:for(int i=0;i<arr.length;i++){
Innter: for(int j=i+1;j<arr.length;j++){
if(arr[i]==arr[j]){
System.out.println(arr[i]);
break Outer;
}
}
}
/*String s="ffaghglklklh";
Outer:for(int i=0;i<s.length();i++){
Innter: for(int j=i+1;j<s.length();j++){
if(s.charAt(i)==s.charAt(j)){
System.out.println(s.charAt(i));
break Outer;
}
}
}*/
}

}

Java Outer and Inner loop example

Program to find or print first repeated/duplicate element



  1. public class Array {

  2. public static void main(String[] args) {
  3. int[] arr={1,2,3,4,5,0,0,1,3};
  4. Outer:for(int i=0;i<arr.length;i++){
  5. Innter: for(int j=i+1;j<arr.length;j++){
  6. if(arr[i]==arr[j]){
  7. System.out.println(arr[i]);
  8. break Outer;
  9. }
  10. }
  11. }
  12. /*String s="ffaghglklklh";
  13. Outer:for(int i=0;i<s.length();i++){
  14. Inner: for(int j=i+1;j<s.length();j++){
  15. if(s.charAt(i)==s.charAt(j)){
  16. System.out.println(s.charAt(i));
  17. break Outer;
  18. }
  19. }
  20. }*/
  21. }

  22. }


2017-06-05

Web crawlers

Web crawlers (web spider) is a search engines software use to traverse the Internet and to save each of the individual pages passed by along the way. Search engines then use additional software to index each of the saved pages, creating a database containing all the words in the pages.

Internet search engines like Google, Yahoo and Bing can search the Internet on topic and return a list of results so quickly. Obviously it would be impossible to search all the Web pages for each request in real time.

Search engine indexed Web pages into highly optimized databases and search matches the keyword each search.

java Interface

Interface
An interface is similar to an abstract class. However, it can only include
abstract methods and final fields (constants), and it can’t be used as a base
class. Instead, a class implements an interface by providing an implementation
for each method declared by the interface.
Here’s a basic interface that defines a single method, named Playable, that
includes a single method named play:
public interface Playable
{
void play();
}
This interface declares that any class that implements the Playable interface
must provide an implementation for a method named play that accepts
no parameters and doesn’t return a value.

This interface has a few interesting details:
✦ The interface itself is declared as public so that it can be used by other
classes. Like a public class, a public interface must be declared in a
file with the same name. Thus, this interface must be in a file named
Playable.java.

Java Abstract Classes

Using Abstract Classes
Java lets you declare that a method or an entire class is abstract, which
means that the method has no body. An abstract method is just a prototype
for a method: a return type, a name, a list of parameters, and (optionally) a
throws clause.
To create an abstract method, you specify the modifier abstract and
replace the method body with a semicolon:
public abstract int hit(int batSpeed);
Here, the method named hit is declared as an abstract method that returns
an int value and accepts an int parameter.
A class that contains at least one abstract method is called an abstract class,
and must be declared with the abstract modifier on the class declaration.
For example:
public abstract class Ball
{
public abstract int hit(int batSpeed);
}
If you omit the abstract modifier from the class declaration, the Java
compiler coughs up an error message to remind you that the class must be
declared abstract.

Packages and Java Doc

PACKAGES  and JAVA DOC

Packages enable you to keep your classes separate from classes in the Java
API, allow you to reuse your classes in other applications, and even let you
distribute your classes to others, assuming other people might be interested
in your classes. If that’s the case, you probably won’t want to just send those people all your separate class files. Instead, you want to bundle them into a single file called a JAR file.

Finally, you find out how to use a feature called JavaDocs that lets you add documentation comments to your classes. With JavaDocs, you can build professional looking documentation pages automatically. Your friends will think you’re a real Java guru when you post your JavaDoc pages to your Web site.

Working with Packages
A package is a group of classes that belong together. Without packages, the entire universe of Java classes would be a huge unorganized mess. Imagine the thousands of classes that are available in the Java API combined with millions of Java classes created by Java programmers throughout the world, all thrown into one big pot. Packages let you organize this pot into smaller, manageable collections of related classes.

understanding java bean with example and best explanation

JAVA BEAN

A JavaBean is a special type of Java class that you can use in several interesting ways to simplify program development. Some beans, such as Swing components, are designed to be visual components that you can use in a GUI editor to quickly build user interfaces. Other beans, known as Enterprise JavaBeans, are designed to run on special EJB servers and can run the data access and business logic for large Web applications.
In this chapter, I look at a more modest type of JavaBean that’s designed to simplify the task of building Java Server Pages. In a nutshell, you can use the simple JavaBeans to build Java Server Pages without writing any Java code in the JSP itself. JavaBeans let you access Java classes by using special HTML-like tags in the JSP page.

Features of Java Beans
A JavaBean is any Java class that conforms to the following rules:
✦ It must have an empty constructor. That is, a constructor that accepts no parameters. If the class doesn’t have any constructors at all, it qualifies because the default constructor has no parameters. But if the class has at least one constructor that accepts one or more parameters, it must also have a constructor that has no parameters to qualify as a JavaBean.
✦ It must have no public instance variables. All the instance variables defined by the class must be either private or protected.
✦ It must provide methods named getProperty and setProperty to get and set the value of any properties the class provides, except for boolean properties that use isProperty to get the property value. The term property isn’t really an official Java term. In a nutshell (or should it be, in a

2017-06-02

program to remove multiple white spaces from a string

Remove multiple extra white spaces from a string if in present in between a string



  • public class WhiteSpace {
  • public static String removeSpace(String string) {
  • String str = "";
  • int length = string.length();
  • if (length <= 0) {
  • return str;
  • }
  • boolean start = true;
  • boolean first = false;
  • for (int i = 0; i < length; i++) {
  • char c = string.charAt(i);
  • if (c == ' ') {
  • if (start) {
  • if(first)
  • str += c;
  • start = false;
  • }
  • }else {
  • first=true;
  • str += c;
  • start = true;
  • }

  • }
  • return str.trim();
  • }
  • public static void main(String[] args) {
  • String str="  g  fdf  dddd      dfd  g   sdfasdf      ff";
  • System.out.println(removeSpace(str));
  • }

  • }

Robert bosch Interview questions

Robert Bosch Engineering and Business Solutions
Koramangala
Bangalore

Other location: Electronic city, Bommanahalli, koramangala, adugodi, EcoSpace Bellandur, Marathahalli

Interview Process:  There are Five round of interview
Technical Interview 1:  Around 1 hr
                                     Self introduction
                                      Explain about project roles and responsibility.
                                      Some basic C,C++,Java question
                                      (Opps concept, Exception , thread, Database,  String, HTML, Javascript)
                                      Design Pattern
                                      angularjs basics if you know
                                     They will ask you to write some basic Program:
                                            java pattern programs
                                            factorial program
                                            reverse a number
                                            Programs on arrays
                                            Programs on factorial

List of government mbbs medical entrance exams 2018

MBBS Entrance Exams – Medical Entrance Test 2018
All notification registration, last date, Exam Date.


NEET (National Entrance cum Eligibility Test)


Notification:
Registration Date: Not yet announce
Exam Date: Not yet announce
Registration Link: Not yet announce 



AIIMS MBBS( AIIMS MBBS entrance exam)


Notification:
Registration Date: Not yet announce
Exam Date: Not yet announce
Registration Link: Not yet announce 

2017-06-01

How do i cancel all my pending friend requests on facebook

If you are not able to send friend request to any more. Which means you have send lots of friends request and it not yet accepted.

You cant send any more request because it all pending for approval.
If you cancel all pending request which are tot accepted, then you can send new request.

Follow the step to cancel all pending request:
  • Login to your Facebook account
  • Go to your Profile
  • Go to Activities
  •  In activity screen you can see all your activities.
  • here you can see friend request send 
  • you can visit to the particular user 
  • and you cancel send request