Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:48:03+00:00 2026-06-09T04:48:03+00:00

import java.lang.reflect.Method; import java.util.Arrays; public class Test { public static void main(String s[]) throws

  • 0
import java.lang.reflect.Method;
import java.util.Arrays;

public class Test
{
     public static void main(String s[]) throws ClassNotFoundException
     {
        Class cls = Class.forName("Test");
        System.out.println("Class is "+cls);
        Method[] mtds = cls.getMethods();
        System.out.println("Methods are "+Arrays.deepToString(mtds));  // not having all methods
    }

    void reflectionTestMethod()
    {
        System.out.println("test");
    }
}

Output is

Class is class Test

Methods are [public static void
Test.main(java.lang.String[]) throws java.lang.ClassNotFoundException,
public final void java.lang.Object.wait() throws
java.lang.InterruptedException, public final native void
java.lang.Object.wait(long) throws java.lang.InterruptedException,
public final void java.lang.Object.wait(long,int) throws
java.lang.InterruptedException, public boolean
java.lang.Object.equals(java.lang.Object), public java.lang.String
java.lang.Object.toString(), public native int
java.lang.Object.hashCode(), public final native java.lang.Class
java.lang.Object.getClass(), public final native void
java.lang.Object.notify(), public final native void
java.lang.Object.notifyAll()]

Why is reflectionTestMethod() not available in the output ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:48:05+00:00Added an answer on June 9, 2026 at 4:48 am

    getMethods() returns public methods (as it states in its Javadoc)

    Try getDeclaredMethods() instead or make the method public.

    BTW, you can do:

    Class cls = Test.class;
    System.out.println("Class is " + cls);
    for(Method method : cls.getDeclaredMethods())
        System.out.println(method);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import java.lang.reflect.Method; public class ClassLoadingTester { public static void main(String a[]){ try{ ClassLoader loader=new
import java.lang.System; public class Splitter{ public static void main(String args[]){ String path_separator = Path
import java.lang.Math; public class NewtonIteration { public static void main(String[] args) { System.out.print(rootNofX(2,9)); }
import java.util.Scanner; public class CourseSplitter { public static void main(String args[]){ Scanner keyboard =
Here is a sample code package org.example; import java.lang.reflect.Method; class TestRef { public void
Here is a test class: import java.lang.annotation.Annotation; import java.lang.reflect.Method; public class TestAnnotations { @interface
import java.lang.reflect.Array; public class PrimitiveArrayGeneric { static <T> T[] genericArrayNewInstance(Class<T> componentType) { return (T[])
I'm trying to run the following code: import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class Reflection
Given this code : package db; import java.sql.*; public class Main { public static
import java.io.*; import java.lang.*; public class Propogate1 { String reverse(String name) { if(name.length()==0) throw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.