get posts in category code example

Example 1: get_posts category

$defaults_param = array(
				'numberposts'      	=> -1,
				'post_type'        	=> 'post',
				'category' 			=> 40 ,
				'suppress_filters'	=> false
			);
$get_featured_post = get_posts($defaults_param);

Example 2: show all posts from category

<?php
    $args = array( 'category' => 7, 'post_type' =>  'post' ); 
    $postslist = get_posts( $args );    
    foreach ($postslist as $post) :  setup_postdata($post); 
    ?>  
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 
    <?php the_excerpt(); ?>  
    <?php endforeach; ?>