Posts

Showing posts from December, 2020

Arrays programms

 Arrays coding round interview programms. 1] BinarySearch package com.hefshine.arrayscw; import java.util.Scanner; public class BinarySearch { int size, search; int mid; void binary() { Scanner sc = new Scanner(System.in); System.out.println("enter size of an array: "); size = sc.nextInt(); System.out.println("enter element of an array "); int[] array = new int[size]; for (int i = 0; i < size ; i++) { array[i] = sc.nextInt(); } System.out.println("enter search :"); search = sc.nextInt(); int first = 0; int last = size - 1; boolean flag = true; while (first <= last) { mid = (first + last) / 2; if (array[mid] == search) { flag = false; System.out.println("element fount at : " + mid); break; } else if (array[mid] < search) { first = mid + 1; } else { last = mid - 1; } } if (flag) { System.out.println("invalid element"); } }...

Interview Question on Abstraction

Interview question on abstraction   Is it compulsory for a class which is declared as abstract to have at least one abstract method? Not need. Abstract class may or may not have abstract methods.

Interview questions on method overloading

Overloading What is method overloading? In a class, Overloaded Method having same name but different parameters or  Overloaded methods will have same name but different number of arguments or different types of arguments.

Interview questions on type casting

  Interview questions on type casting What is type casting.? When the data is converted from one data type to another data type, then it is called type casting. type casting is nothing but changing the type of the data.

Interview questions on modifier

  Interview questions on modifier W are access modifiers in java.? These are the modifiers which are used to restrict the visibility of a class or a field or a method or a constructor. Java supports 4 access modifiers. a) private  : private fields or methods or constructors are visible within the class in which they are defined. b) protected  : Protected members of a class are visible within the package but they can be inherited to sub classes outside the package. c) public :  public members are visible everywhere. d) default or No-access modifiers :  Members of a class which are defined with no access modifiers are visible within the package in which they are defined.

Interview questions on inheritance

 Questions on inheritance

Interview questions on constucture

                                                     ON CONSTRUCTOR   1) What is constructor chaining? Constructor Chaining is a technique of calling another constructor from one constructor.  this()  is used to call same class constructor where as  super()  is used to call super class constructor.

STRING IN JAVA

Image
  STRING

Interface VS Abstract class

Difference  abstract class vs interface Abstract class 1)Abstract class can have both an abstract as well as concrete methods. 2) Multiple Inheritance is not supported in abstract class. 3) final, non-final, static , non-static variables are supported. 4) Abstract class declared using abstract keyword. 5) Abstract class can be inherited using extends keyword. 6) Abstract class can have any type of members like private, public.

ADAPTOR CLASS

  Adapter class

MARKER INTERFACE IN JAVA

Image
  MARKER INTERFACE 

INTERFACE IN JAVA

Image
  Interface in Java

ENCAPSULATION IN JAVA

Image
Encapsulation

ABSTRACTION IN JAVA

Image
  Abstract class in Java A class which is declared with the abstract keyword is known as an abstract class in java. It can have abstract and non-abstract methods (method with the body). Abstraction in Java Abstraction  is a process of hiding the implementation details and showing only functionality to the user. Points An abstract class must be declared with an abstract keyword. It can have abstract and non-abstract methods. It cannot be instantiated. It can have constructe and static methods also. It can have final methods which will force the subclass not to change the body of the method. Abstract Method in Java A method which is declared as abstract and does not have implementation is known as an abstract method. abstract void print(); //no method body and abstract eg - // Abstract class abstract class Animal {   // Abstract method    public abstract void animalSound();   // Regular method   public void eat() {     System.out.println("...

JVM IN JAVA

Image
JVM  in Java

POLYMORPHISM IN JAVA

  POLYMORPHISM One name but multiple form is concept of polymorphism. This allows us to perform a single action in different ways.

JAVA FUNDAMENTAL

Image
JAVA FUNDAMENTAL

TYPE CASTING IN JAVA

Java Type Casting Through type casting we are not creating any new object .for existing object we are providing another type of refference variable. Type casting is when you assign a value of one primitive data type to another type.

METHOD OVERRIDING IN JAVA

Image
Method Overriding in Java I subclass (child class) has the same method as declared in the parent class, it is known as  method overriding in Java . Usage of Java Method Overriding Method overriding is used to provide the specific implementation of a method which is already provided by its superclass. Method overriding is used for runtime polymorphism Rules for Java Method Overriding The method must have the same name as in the parent class The method must have the same parameter as in the parent class. There must be an IS-A relationship (inheritance). Real life example

METHOD OVERLOADING IN JAVA

Image
Method Overloading in Java If a class has multiple methods having same name but different in parameters, it is known as  Method Overloading . There are two ways to overload the method in java By changing number of arguments By changing the data type

JAVA INHERITANCE

Image
inheritance in java Inheritance in Java  is a mechanism in which one object acquires all the properties and behaviors of a parent object. It is an important part of OOps(Object Oriented programming system. Inheritance represents the  IS-A relationship  which is also known as a  parent-child  relationship. Why use inheritance in java For Method Overriding(so runtime polymorphism can be achieved). For Code Reusability.

C++ vs Java

C++ vs Java There are many differences and similarities between the c++ language and java. . A list of top differences between C++ and Java are given below: C++ EXAMPLE File: main.cpp #include <iostream>    using   namespace  std;   int  main() {      cout <<  "Hello C++ Programming" ;       return  0;   }   JAVA EXAMPLE class  Simple{        public   static   void  main(String args[]){        System.out.println( "Hello Java" );       }   }  

FEATURES OF JAVA

List of most important Java features Simple Object-Oriented Portable Platform independent Secured Robust Architecture neutral Interpreted High Performance Multithreaded Distributed Dynamic  Simple Java is very easy to learn, and its syntax is simple, clean and easy to understand. 

HISTORY OF JAVA

History of java     Initially developed by James Gosling at sun sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995. In 1995, Time magazine called  Java one of the Ten Best Products of 1995 .    Java team members  initiated this project to develop a language for digital devices such as set-top boxes, televisions, etc. However, it was suited for internet programming. Later, Java technology was incorporated by Netscape.            The principles for creating Java programming were "Simple, Robust, Portable, Platform-independent, Secured, High Performance, Multithreaded, Architecture Neutral, Object-Oriented, Interpreted, and Dynamic". JAVA was developed by James Gosling , who is known as the father of Java, in 1995.  WHY NAME JAVA - According to James Gosling, "Java was one of the top choices along with  Silk ". Since Java was so unique, most of the team members preferred Jav...

OBJECT ORIENTED CONCEPTS

Image
OOPS CONCEPTS  The popular object-oriented languages are Java, C#,php, Python,c++ etc. The main aim of object-oriented programming is to implement real-world entities.   Java is object oriented programming language. Object oriented programming features- 1) inheritance 2) encapsulation 3) abstraction 4) polymorphism    - run time polymorphism    - compile time polymorphism 5) association 6) composition 7) aggregation. Object Any entity that has state and behavior is known as an object. For example, a chair, pen, table, keyboard, bike, etc. It can be physical or logical. Class Collection of objects is called class. It is a logical entity. A class can also be defined as a blueprint from which you can create an individual object. Class doesn't consume any space.