Skip to main content

Posts

Core Java Basic Classes

😏 Core Java Classes Brief Introduction Topics : #Abstract Class : An Abstract Class is a class that is declared keyword abstract. it may  or may not include an abstract method Abstract method: A method that is a declared as abstract and does not have an implementation. The abstract class can look something like this: abstract class GraphicObject { int x, y; ... void moveTo(int newX, int newY) { ... } abstract void draw(); abstract void resize(); } #Interface class : An interface class in java is a blueprint of a class, it has static constant and abstract method.there  can be the only abstract method in Java interface .(is-a relationship) The Interface class can look something like this: interface Bicycle { // wheel revolutions per minute void changeCadence(int newValue); void changeGear(int newValue); void speedUp(int increment); void applyBrakes(int decrement); } #Marker Interface...

Java String Reverse

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.(Wikipedia) Given a string  , print  Yes  if it is a palindrome, print  No  otherwise. Constraints  will consist at most   lower case english letters. Sample Input madam Sample Output Yes import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String A=sc.next(); /* Enter your code here. Print output to STDOUT. */ String result ="Yes"; int length = A.length(); for (int i=0; i<length/2;i++){ if(A.substring(i,i+1).equals(A.substring(length-i-1,length-i))) { }else { result ="No"; } } System.out.println(result); } }

OOPS Concepts in Java

Object-oriented programming language (OOPL) is high-level programming language based on the object-oriented programming (oop's) model. that provide many concepts such as inheritance, data binding, polymorphism etc. OOP'S Concepts : Object & Class  Abstraction Encapsulation Polymorphism Inheritance #Object:   Any entity that has state & behavior is known as an object. #Class:   A class is the blueprint of the object or Collection of the object is class. #Abstraction: Hiding Internal details and showing functionally is known as abstraction  #Encapsulation : Binding (or wrapping) code and data together into a single unit as known as encapsulation #Inheritance :  When one object acquires all the properties and behavior of the parent object. #Polymorphism : When one task is performed in different ways, we only use method overloading and overriding  Overloading : Wh...

Java Substring Comparisons

We define the following terms: Lexicographical Order , also known as  alphabetic  or  dictionary  order, orders characters as follows:  For example,  ball < cat ,  dog < dorm ,  Happy < happy ,  Zoo < ball . A  substring  of a string is a contiguous block of characters in the string. For example, the substrings of  abc  are  a ,  b ,  c ,  ab ,  bc , and  abc . Given a string,  , and an integer,  , complete the function so that it finds the lexicographically  smallest  and  largest substrings of length  . Input Format The first line contains a string denoting  . The second line contains an integer denoting  . Constraints  consists of English alphabetic letters only (i.e.,  [a-zA-Z] ). Output Format Return the respective lexicographically smallest and largest substrings as a s...