in Education by

What are the difference between a static class and a singleton class?

1 Answer

0 votes
by

What are the difference between a static class and a singleton class?

Following are the differences between a static class and a singleton class.

A static class can not be a top level class and can not implement interfaces where a singleton class can.

All members of a static class are static but for a Singleton class it is not a requirement.

A static class get initialized when it is loaded so it can not be lazily loaded where a singleton class can be lazily loaded.

A static class object is stored in stack whereas singlton class object is stored in heap memory space.

Related questions

0 votes
    What is singleton class in android?...
asked Jan 14, 2021 in Technology by JackTerrance
0 votes
    How can you create Singleton class in java?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    What is the difference between Static and Dynamic resources?...
asked Apr 9, 2021 in Education by JackTerrance
0 votes
    What is the difference between global and static global variables?...
asked Jan 23, 2021 in Technology by JackTerrance
0 votes
    How many copies of static and class variables are created when 10 objects are created of a class? (a ... questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    I'm using JEE and I created EJB-Singleton. It has as a field LRUMap, which represents cache to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Which annoatation is used to inject singleton services like timer service into an ejb?...
asked Nov 7, 2020 in Technology by JackTerrance
0 votes
    How to prevent cloning of a singleton object?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    Can we create a clone of a singleton object?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    What is Singleton pattern?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    What are the wrapper classes ? What is the difference between scanner class and wrapper class ? 100 points . Select the correct answer from above options...
asked Dec 28, 2021 in Education by JackTerrance
0 votes
    What should be the execution order, if a class has a method, static block, instance block, and ... stackoverflow.com 🔗Source: Java Interview Questions and Answers...
asked Dec 19, 2020 in Technology by Editorial Staff
0 votes
    Class 10 ICSE Computer Applications -What is static binding? No spam plz Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    class Modulus { public static void main(String args[]) { double a = 25.64; int b = 25; a = a % 10; b = b % 10; ... (a + + b); } } Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    class year { public static void main() { int a=2000; if( a%4 == 0 && a%100 != 0); { System.out.println ... this it is showing 2 errors Select the correct answer from above options...
asked Dec 9, 2021 in Education by JackTerrance
...