Posts

Explain Abstract class with suitable example.

  Abstract Class :                                                                - Abstract is a keyword.                                                                        - Abstract class is declared abstract.                                                                        - Abstract class can't be create an instanc...

Gregorian Calendar class in java

  GregorianCalendar class: import java.util.*; class GregorianCalendar {      public static void main(String args[])      { GregorianCalendar obj=new GregorianCalendar(); System.out.println(obj.get(Calendar.DATE)); System.out.println(obj.get(Calendar.MONTH)); System.out.println(obj.get(Calendar.YEAR)); System.out.println(obj.getTimeZone());      } }

Hashtable class in Java.

Hashtable class : import java.util.*; class a  { public static void main(String args[]) {                Hashtable ht=new Hashtable();      System.out.println(ht.isEmpty()); // return true      ht.put(101,"ABC");      ht.put(102,"DEF");      ht.put(103,"GHI");      System.out.println(ht.isEmpty()); //return false      System.out.println(ht.size());   //count total number of record      System.out.println(ht.get(102));  //display specific data } } OUTPUT:          true          false          3          DEF

Math method using java.util package.

  // Math Function using java.util.*;  package import java.util.*; class a {         public static void main(String args[])      {         Scanner s=new Scanner(System.in);         System.out.print("Enter Value : ");         int n=s.nextInt();         System.out.print("Enter Value : ");         int p=s.nextInt();           System.out.println("Square root : "+Math.sqrt(n)); System.out.println("Log value : "+Math.log(n)); System.out.println("Maximum value : "+Math.max(n,p)); System.out.println("Mininum value : "+Math.min(n,p)); System.out.println("Power : "+Math.pow(n,p)); double d=25.8; System.out.println("Ceil : "+Math.ceil(d)); System.out.println("Sin value : "+Math.sin(d)); System.out.println("Cos value : "+Math.cos(d)); System.out.println("Tan value : "+Math.tan(d)); System.out....

Explain Multi-level Inheritance with suitable example.

Image
- The mechanism of deriving a class from another derived class is known as Multi-Level Inheritance . Example :                                    Diagram of Multi-Level Inheritance class A {     public A()     {           System.out.println("Class A");     } } class B extends A {     public B()     {           System.out.println("Class B");     } } class C extends B {     public C()     {         System.out.print("Class C");     } } class D {     public static void main(String arg[])     {       C obj=new C();     } }

What is Single Inheritance? Explain it with example.

Image
- The mechanism of deriving a new class from an old one is called Inheritance. - One class derived into another class is called Single Inheritance. - A derive class with only one base class is called Single Inheritance. Example :                                                              Figure of Single Inheritance import java.util.Scanner; class A {     int i;     public void sq(int n)     {          i=n*n;     } } class B extends A {     public void set()     {          System.out.print("Square is : "+i);      } } class Square {     public static void main(String arg[])     {          B obj=new B();          ...

Explain JDK and its components.

What is JDK ?                               - JDK stands for Java Development Kit.                               - It is a collection of tools which are used for developing and running the Java program. JDK Components :                          (1) appletviewer :                                                  - It is used to view the java applets without using the browser.                       (2) javac :                         ...

What is Java? Explain Java Features.

  What is Java ? Explain Java Features.  - Java is a programming language that :-                                                                                 - Is exclusively object oriented.                                                                                - Has full GUI support.                                                      ...

Java Data Types

Image
There are two types of datatypes :-                                                                         1) Primitive Datatypes                                                                   2) Non-Primitive Datatypes 1) Primitive Data Types :               - Java provides eight primitive types of data.               - 1) byte                    2) short               - 3) int       ...

OOP Concepts In Java

  OOP Concepts :                         - OOP Stands for Object Oriented Programming .                         - It depends on c lass and object .                         - It is a secure rather than POP(Procedure Oriented Programming)structure.                              - Secure the code and data.                            Class :                          - Where the data and code are bound together in a single unit is called class .                ...